Skip to content

Instantly share code, notes, and snippets.

View BenjaminLaschkar's full-sized avatar

Benjamin BenjaminLaschkar

  • Echosens
  • France
View GitHub Profile
@BenjaminLaschkar
BenjaminLaschkar / MultiplicationTests.kt
Created June 2, 2022 09:43
MultiplicationTests.kt
assertEquals("40", result)
@BenjaminLaschkar
BenjaminLaschkar / MultiplicationTests.kt
Created June 2, 2022 09:42
MultiplicationTests.kt
val result = driver.findElement(By.className("android.widget.TextView")).text
@BenjaminLaschkar
BenjaminLaschkar / MultiplicationTests.kt
Created June 2, 2022 09:41
MultiplicationTests.kt
driver.findElement(By.id(DIGIT_5)).click()
driver.findElement(By.id(MULTIPLICATION)).click()
driver.findElement(By.id(DIGIT_8)).click()
driver.findElement(By.id(EQUAL)).click()
@BenjaminLaschkar
BenjaminLaschkar / MultiplicationTests.kt
Created June 2, 2022 09:40
MultiplicationTests.kt
import org.junit.jupiter.api.Test
import org.openqa.selenium.By
import kotlin.test.assertEquals
class MultiplicationTests : AppiumSetup() {
@Test
fun `Simple multiplication gives correct result`() {
// Let's implement this !
}
}
const val DIGIT_5: String = "com.google.android.calculator:id/digit_5"
const val DIGIT_8: String = "com.google.android.calculator:id/digit_8"
const val MULTIPLICATION: String = "com.google.android.calculator:id/op_mul"
const val EQUAL: String = "com.google.android.calculator:id/eq"
@BenjaminLaschkar
BenjaminLaschkar / AppiumSetup.kt
Last active June 7, 2022 10:02
AppiumSetup.kt
@JvmStatic
@AfterAll
fun tearDown() {
driver.quit()
}
@JvmStatic
@BeforeAll
fun setUp() {
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, platformName)
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, automationName)
caps.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, appPackage)
caps.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, activityName)
caps.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true)
driver = AndroidDriver(URL(serverUrl), caps)
}
private const val appPackage = "com.google.android.calculator"
private const val activityName = "com.android.calculator2.Calculator"
private const val automationName = "UiAutomator2"
private const val platformName = "Android"
private const val serverUrl = "http://localhost:4723/wd/hub"
lateinit var driver: AppiumDriver<MobileElement>
private val caps = DesiredCapabilities()
@BenjaminLaschkar
BenjaminLaschkar / build.gradles.kts
Last active June 2, 2022 09:16
build.gradles.kts
dependencies {
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
testImplementation("io.appium:java-client:7.6.0")
testImplementation("org.seleniumhq.selenium:selenium-java:4.1.4")
}