class io.appium.java_client.AppiumDriver cannot be cast to class org.openqa.selenium.interactions.HasTouchScreen (io.appium.java_client.AppiumDriver and org.openqa.selenium.interactions.HasTouchScreen are in unnamed module of loader 'app') code example

Example: class io.appium.java_client.AppiumDriver cannot be cast to class org.openqa.selenium.interactions.HasTouchScreen (io.appium.java_client.AppiumDriver and org.openqa.selenium.interactions.HasTouchScreen are in unnamed module of loader 'app')

public void scrollDown()  {

    //The viewing size of the device
    Dimension size = driver.manage().window().getSize();

    //x position set to mid-screen horizontally
    int width = size.width / 2;

    //Starting y location set to 80% of the height (near bottom)
    int startPoint = (int) (size.getHeight() * 0.80);

    //Ending y location set to 20% of the height (near top)
    int endPoint = (int) (size.getHeight() * 0.20);

    new TouchAction(driver).press(PointOption.point(width, startPoint)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000))).moveTo(PointOption.point(width, endPoint)).release().perform();

}

Tags:

Misc Example