How can i scroll up and down by using WebDriver?

How can i scroll up and down by using WebDriver?
I create a cast but no result …
org.openqa.selenium.remote.RemoteWebDriver cannot be cast to io.appium.java_client.MobileDriver

Do not create reference of RemoteWebdriver , create a reference of AndroidDriver i.e.
driver = new AndroidDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
then you can use driver.scrollToExact("Help").click();

1 Like

OK, i will but those changes don’t influence on my code?

@emna_ayadi Not much. Advantage using AndroidDriver is you can access your all RemoteWebDriver APIs as well as new APIs supported by AndroidDriver.

1 Like

Ok, thx a lot :smile:

1 Like

How can i navigate by swipping from right to left?

		driver.context("NATIVE_APP"); 
		Dimension size = driver.manage().window().getSize(); 
		int startx = (int) (size.width * 0.8); 
		int endx = (int) (size.width * 0.20); 
		int starty = size.height / 2; 
		driver.swipe(startx, starty, endx, starty, 1000);

Use above code. Change startx to starty if you wish to swipe in opposite direction.

1 Like

Swipe works fine now, but the problem when i swipe and i want to hit delete or modify buttons i can’t ! Swipe menu get disappear immediately after it appears

do the multipliers (0.8 and 0.20) depend on the device type or dimensions of the device? For example, I’m using iOS and need to perform a scroll up and down action. Do I need to change the multiplier values accordingly?

Also, could anyone explain what the 0.8 and 0.2 mean? Where do we arrive at those specific numbers from?