mirror of
https://github.com/appium/appium.git
synced 2026-01-13 13:50:00 -06:00
Added More Tests (#11022)
* Added More Tests Android Native Android Browser Android Sauce Labs iOS Native iOS Browser iOS Sauce Labs * Removed Duplicate Tests * Removed Appium Version and changed AutomationName to UIAutomator2
This commit is contained in:
committed by
Sai Krishna
parent
174912ab3a
commit
bec8462016
44
sample-code/java/src/AndroidBrowserSaucelabsTest.java
Normal file
44
sample-code/java/src/AndroidBrowserSaucelabsTest.java
Normal file
@@ -0,0 +1,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");
|
||||
}
|
||||
}
|
||||
46
sample-code/java/src/IOSBrowserSaucelabsTest.java
Normal file
46
sample-code/java/src/IOSBrowserSaucelabsTest.java
Normal file
@@ -0,0 +1,46 @@
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
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 io.appium.java_client.ios.IOSDriver;
|
||||
import io.appium.java_client.remote.MobileCapabilityType;
|
||||
|
||||
/**
|
||||
* IOS Browser Sauce Labs Test.
|
||||
*/
|
||||
public class IOSBrowserSaucelabsTest 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 IOSDriver<?> mobiledriver;
|
||||
|
||||
@BeforeTest
|
||||
public void beforeTest( ) throws MalformedURLException {
|
||||
DesiredCapabilities capabilities = new DesiredCapabilities();
|
||||
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.2.2");
|
||||
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"iOS");
|
||||
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"XCUITest");
|
||||
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
|
||||
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari");
|
||||
capabilities.setCapability("newCommandTimeout", 2000);
|
||||
mobiledriver = new IOSDriver<>(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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user