Created
August 25, 2017 03:39
-
-
Save travisdachi/0ac4eb1219bd62d15b7d2e8ca5dc248a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SampleTest { | |
lateinit var driver: AppiumDriver<WebElement> | |
val platform = MobilePlatform.IOS | |
@Before | |
fun setup() { | |
if (platform == MobilePlatform.ANDROID) { | |
val dir = System.getProperty("user.dir") | |
val path = Paths.get(dir, "apps/hello-appium.apk") | |
val capabilities = DesiredCapabilities().apply { | |
setCapability(MobileCapabilityType.PLATFORM_NAME, "Android") | |
setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator") | |
setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2) | |
setCapability(MobileCapabilityType.APP, path.toAbsolutePath().toString()) | |
} | |
driver = AppiumDriver<WebElement>(URL("http://0.0.0.0:4723/wd/hub"), capabilities) | |
} else if (platform == MobilePlatform.IOS) { | |
val dir = System.getProperty("user.dir") | |
val path = Paths.get(dir, "apps/HelloAppium.app") | |
val capabilities = DesiredCapabilities().apply { | |
setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS") | |
setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 7") | |
setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.3") | |
setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST) | |
setCapability(MobileCapabilityType.APP, path.toAbsolutePath().toString()) | |
} | |
driver = AppiumDriver<WebElement>(URL("http://0.0.0.0:4723/wd/hub"), capabilities) | |
} | |
driver.manage().timeouts().implicitlyWait(30L, TimeUnit.SECONDS) | |
} | |
@After | |
fun tearDown() { | |
driver.quit() | |
} | |
@Test | |
fun testGreet() { | |
val mainPage = MainPage(driver) | |
Assert.assertTrue(mainPage.myLabel.text == "Label") | |
mainPage.myButton.click() | |
Assert.assertTrue(mainPage.myLabel.text == "Hello Appium") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment