Scroll on Android Chrome with Appium/Ruby

Hello,
I’m trying to scroll on Android Chrome on real device but I can’t find a way.

My capabilities are:

capabilities = {
caps: {
‘browserName’ => ‘Chrome’,
‘platformName’ => ‘Android’,
‘deviceName’ => ‘Android’
},
appium_lib: {
sauce_username: nil, # don’t run on Sauce
sauce_access_key: nil
}
}
@driver_appium = Appium::Driver.new(capabilities)
@driver = @driver_appium.start_driver
@browser = Watir::Browser.new @driver
@browser.driver.manage.timeouts.implicit_wait = 5

I’ve tried:
@driver_appium.scroll_to(‘my text’)
and
@driver_appium.scroll_to(‘my text’)
But I still have :
undefined method `scroll_to’ for nil:NilClass (NoMethodError)

I’ve tried too:
@browser.execute_script ‘window: scrollBy’, x: 0, y: -500
But nothing happens (but at least I don’t an error).

So what is the best way to scroll on Android Chrome with ruby ?
Thanks a lot guys

@bootstraponline?
Can you take look with your Ruby-eyes?

Sure, the problem is scroll_to only works on native apps. The implementation is based on UiSelectors and UiScrollable scrollIntoView. Neither of these work with Android Chrome.

For scrolling on a web browser, I recommend automating a swipe gesture in a loop with a timeout and checking if the text exists or not.

1 Like
driver.execute_script("window.scrollBy(0,250);")

That worked for me with Ruby + Android + Appium for browser scrolling

@garyst1981 In my case your solution didn’t work on Nexus 5 + Chrome

I had to use below to scroll to element and click it

((JavascriptExecutor) getDriver()).executeScript("arguments[0].scrollIntoView(true);", getDriver().findElement(By.xpath("//a[contains(text(),'Reset Password')]")));

Hey,

I tried clicking up the element in a list view table, like sign up feature through mobile in whatsapp where you scroll and select country code

driver.scroll_to_exact("India").click

This scrolls down till “India” but doesn’t click on it. Any idea why?