Is there any ways for appium to scroll and find element automatically?

10,983 views
Skip to first unread message

fiona

unread,
Aug 14, 2013, 6:49:21 AM8/14/13
to appium-...@googlegroups.com
Hi there,

I have a long ListView, and it contains several element that i could click on. but cell phone only show part of them on screen once, and then I need to scroll the list up/down to find the exactly element that i want to click.
I remembered that, webdriver could be done it automatically, i tried it by appium, it seems doesnt work, is there any solutions for this? or i just can use it by drag/swipe the view?...

thanks~

Jonathan Lipps

unread,
Aug 14, 2013, 3:22:46 PM8/14/13
to fiona, appium-...@googlegroups.com
I would use swipe to navigate. There's also mobile: scrollTo which has the purpose of scrolling to a specific element.

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

fiona

unread,
Aug 15, 2013, 3:12:18 AM8/15/13
to appium-...@googlegroups.com
hi Jonathan,
seemed that the element should be visible then i could use scroll to? 
my code is like this, it doesnt work, appium said could not locate the element
HashMap<String, String> swipeObject = new HashMap<String, String>();
swipeObject.put("element", Name);
js.executeScript("mobile: scrollTo", swipeObject);


在 2013年8月15日星期四UTC+8上午3时22分46秒,Jonathan Lipps写道:

Jonathan Lipps

unread,
Aug 15, 2013, 10:54:16 AM8/15/13
to fiona, appium-...@googlegroups.com
What is "Name" here? The value of 'element' needs to be the element's internal ID. See the gestures.md docs for more Java examples.

Joel Miele

unread,
Aug 16, 2013, 11:25:28 AM8/16/13
to appium-...@googlegroups.com
Depending on how long the list is, you can use mobile:Find.  For extremely large lists you will probably have to write your own method that uses swipes.

Something that determines which direction to swipe (is first visible element > or < you desired element), and then swiping appropriate distances and checking for the value.  It will be a little slow regardless, but there are probably a few clever solutions our there.

Personally I store all visible values in a data structure and check if my element exists, if not I scroll an amount that presents me with new elements.
Message has been deleted

fiona

unread,
Aug 20, 2013, 5:40:10 AM8/20/13
to appium-...@googlegroups.com
hi Joel, 
I tried mobile:Find, it doesnt work, so i need to write my own method to do this, right?

在 2013年8月16日星期五UTC+8下午11时25分28秒,Joel Miele写道:

fiona

unread,
Aug 20, 2013, 5:44:19 AM8/20/13
to appium-...@googlegroups.com, fiona
Hi ,
its hard to get the internal Id on windows...is there any other ways to do this?
football is not visible at first in the list view, the console said "No element find" , so how could i do this?
WebElement row = driver.findElement(By.name("football"));
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> swipeObject = new HashMap<String, String>();
swipeObject.put("element", ((RemoteWebElement) row).getId());
js.executeScript("mobile: scrollTo", swipeObject);
 driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);

在 2013年8月15日星期四UTC+8下午10时54分16秒,Jonathan Lipps写道:

Satyajit Malugu

unread,
Sep 18, 2013, 12:14:32 PM9/18/13
to appium-...@googlegroups.com, fiona
The pattern I am using in ruby using appium_lib is

scroll_to element_text unless exists {s_text element_text }
s_text element_text

Ramon Cidade

unread,
Mar 21, 2014, 1:53:25 PM3/21/14
to appium-...@googlegroups.com, fiona
Hi fiona,
Did you have found a solution for this?
I'm facing the same issue here... I created a method that search the element but is too flaky :(
Calling mobile: scrollTo in java doesn't work.

bootstrap online

unread,
Mar 21, 2014, 1:54:51 PM3/21/14
to Ramon Cidade, appium-...@googlegroups.com, fiona

Ramon Cidade

unread,
Mar 21, 2014, 2:36:42 PM3/21/14
to appium-...@googlegroups.com, Ramon Cidade, fiona
I was able to get scrollTo working:
Thanks bootstraponline

Валентин Розловенко

unread,
Aug 26, 2014, 10:02:36 AM8/26/14
to appium-...@googlegroups.com
Does anyone has a same solution for robotframework ?
Reply all
Reply to author
Forward
0 new messages