Hi everyone,
if have a question: currently I’m switching from Java to Kotlin which works quite well (also thanks to IntelliJs’ conversion). The only thing that does not work are the TouchActions. And I don’t know how to solve it.
My setup is Appium 6.1.0
Java 1.8
Kotlin 1.2.50
Here is some sample code for Java
@Test
public void testInJava() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
URL url = new URL("http://localhost:4723/wd/hub");
AppiumDriver driver = new AppiumDriver(url, capabilities);
TouchAction touchAction = new TouchAction((PerformsTouchActions) driver);
touchAction.press(PointOption.point(200, 200))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(100)))
.release()
}
And the new code in Kotlin:
fun testInKotlin() {
val capabilities = DesiredCapabilities()
val url = URL("http://localhost:4723/wd/hub")
val driver = AppiumDriver<MobileElement>(url, capabilities)
TouchAction(driver as PerformsTouchActions)
.press(PointOption.point(200, 200))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(100)))
.release()
.perform()
}
My problem is that the type inference of Kotlin fails. Something like TouchAction(driver as PerformsTouchActions)… is needed but all attempts for different types failed and are not accepted by IntelliJ.
Do you have a solution or clue what is needed/ missing?
Thanks,
Flo