I’m trying to scroll through a list that contains unseen objects until the one I want is in view. I tried using scroll_to, but it was failing. When I looked at the source, I see this:
def scroll_to text
text = %Q("#{text}")
args = scroll_uiselector("new UiSelector().textContains(#{text})") +
scroll_uiselector("new UiSelector().descriptionContains(#{text})")
find_element :uiautomator, args
end
This explains my problem – only the text field is set to this value. The description field is empty. Why does Appium::Android::scroll_to and scroll_to_exact match both the text and description? This seem unnecessarily restrictive.
I don’t think you understand the code. scroll_to matches on either the text or the description. If the text or description match then it’s considered a success.
I should have dug deeper. I ended up writing my own code that worked around with the scrollable primitive, but I’m glad to hear I won’t have to maintain that.
Hi @willosser, I have the same problem with scrolling to the element. It performs the scroll, but can’t find an element. Can you share your solution with me please?
I liberated this code from the appium source. In our case, we don’t search by description, so
def scroll_to text
# This is a workaround for Appium issue 4311,
# It can and should be replaced by the following when the issue is resolved
# appium.driver.scroll_to text
text = %Q("#{text}")
args = appium.scroll_uiselector(“new UiSelector().text(#{text})”)
appium.driver.find_element :uiautomator, args
end
def scroll_to(text)
text = %("#{text}")
args = scroll_uiselector(“new UiSelector().textContains(#{text})”)
find_element :uiautomator, arg
end
I am calling from my main script as
element = scroll_to(“Modified email recipents”)
element.txt
I get error as No element found
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/response.rb:70:in `assert_ok’: No element found (Selenium::WebDriver::Error::NoSuchElement
Error)
This method scroll Only upto 15 index elment after tat it is throwing NoSuchElementFoundException in Android .Pls Help me with this issue @sdubov@willosser
@suryasurendar, I haven’t had the chance to update our code base to start using by AndroidUIAutomator. Based on my experience using uiautomator before we adopted Appium, that sounds like a limitation of uiautomator, not Android. Unless you can find an example online, you’ll likely have to create your own scroll_to method to find the desired resource-id.