Anshul Anshul - 3 months ago 41
Ruby Question

Scrolling in android using Appium + Ruby

I am trying to scroll through the android app to find a specific element. Below is the code for scrolling:

def self.swipe_to (programme)
begin
scroll_to(programme)
rescue
puts 'unable to find ' + programme
return false
end
return true
end


The scrolling works fine however, the issue is the app scrolls to the programme but as soon the programme is found, the app scrolls back to the top of the list.
And then an error is thrown saying element could not be found.

Has anybody seen similar kind of issue before? Is there any way to stop scrolling as soon as programme is found? I just want to stop the scrolling back to the top as soon as programme is found. Please help.

Answer

Apparently this seems to be working for me:

scroll_to(programme).click
driver.navigate().back()

I need to click on the element to stop scrolling further and then click back to go to the same page.

Comments