forked from appium/appium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAndroidBrowserSaucelabsTest.java
More file actions
44 lines (39 loc) · 1.84 KB
/
AndroidBrowserSaucelabsTest.java
File metadata and controls
44 lines (39 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Android Browser Sauce Labs Test.
*/
public class AndroidBrowserSaucelabsTest extends BaseTest{
public static final String USERNAME = "YOUR_USERNAME";
public static final String ACCESS_KEY = "YOUR_ACESS_KEY";
public static final String URL = "https://"+USERNAME+":" + ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub";
public static AndroidDriver<?> mobiledriver;
@BeforeTest
public void beforeTest( ) throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.4");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"UiAutomator2");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Samsung Galaxy S4 Emulator");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Browser");
capabilities.setCapability("newCommandTimeout", 2000);
mobiledriver = new AndroidDriver<>(new URL(URL), capabilities);
}
@AfterTest
public void afterTest( ){
mobiledriver.quit();
}
@Test
public static void launchBrowser(){
mobiledriver.get("http://appium.io/");
Assert.assertEquals(mobiledriver.getCurrentUrl(), "http://appium.io/", "URL Mismatch");
Assert.assertEquals(mobiledriver.getTitle(), "Appium: Mobile App Automation Made Awesome.", "Title Mismatch");
}
}