Skip to content

Commit

Permalink
Add appium-capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
eck-song committed Aug 28, 2024
1 parent c256f83 commit 0dc9c00
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ repositories {
}

dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.testng:testng:7.8.0'
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.testng:testng:7.8.0'
implementation 'io.appium:java-client:8.6.0'
}

tasks.register('runMultiplicationTable', JavaExec) {
Expand Down
48 changes: 48 additions & 0 deletions src/main/kotlin/AndroidSetup.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import io.appium.java_client.android.AndroidDriver
import io.appium.java_client.remote.options.BaseOptions
import org.testng.annotations.AfterMethod
import org.testng.annotations.BeforeMethod
import org.testng.annotations.Test
import java.net.MalformedURLException
import java.net.URL

class SampleTest {

private lateinit var driver: AndroidDriver

@BeforeMethod
fun setUp() {
val options = BaseOptions()
.amend("platformName", "Android")
.amend("appium:platformVersion", "14.0")
.amend("appium:deviceName", "Pixel 8 Pro API 34")
.amend("appium:automationName", "UiAutomator2")
.amend("appium:udid", "emulator-5554")
.amend("appium:app", "/Users/eck.song92/Downloads/ApiDemos-debug.apk")
.amend("appium:ensureWebviewsHavePages", true)
.amend("appium:nativeWebScreenshot", true)
.amend("appium:newCommandTimeout", 3600)
.amend("appium:connectHardwareKeyboard", true)

driver = AndroidDriver(getUrl(), options)
}

private fun getUrl(): URL {
return try {
URL("http://127.0.0.1:4723")
} catch (e: MalformedURLException) {
e.printStackTrace()
throw RuntimeException("Invalid URL")
}
}

@Test
fun sampleTest() {
Thread.sleep(10000)
}

@AfterMethod
fun tearDown() {
driver.quit()
}
}
48 changes: 48 additions & 0 deletions src/main/kotlin/iOSSetup.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import io.appium.java_client.ios.IOSDriver
import io.appium.java_client.remote.options.BaseOptions
import org.openqa.selenium.WebDriver
import org.testng.annotations.AfterMethod
import org.testng.annotations.BeforeMethod
import org.testng.annotations.Test
import java.net.MalformedURLException
import java.net.URL
import java.time.Duration

class iOSSetup {

private lateinit var driver: IOSDriver

@BeforeMethod
fun setUp() {
val options = BaseOptions()
.amend("platformName", "iOS")
.amend("appium:platformVersion", "17.5")
.amend("appium:automationName", "XCuiTest")
.amend("appium:udid", "1F669193-7A3A-401C-8BFE-7101F0DE7471")
.amend("appium:app", "/Users/eck.song92/Downloads/TestApp.app")
.amend("appium:includeSafariInWebviews", true)
.amend("appium:newCommandTimeout", 3600)
.amend("appium:connectHardwareKeyboard", true)

driver = IOSDriver(getUrl(), options)
}

private fun getUrl(): URL {
return try {
URL("http://127.0.0.1:4723")
} catch (e: MalformedURLException) {
e.printStackTrace()
throw RuntimeException("Invalid URL")
}
}

@Test
fun sampleTest() {
Thread.sleep(10000)
}

@AfterMethod
fun tearDown() {
driver.quit()
}
}

0 comments on commit 0dc9c00

Please sign in to comment.