scroll_to an element

787 views
Skip to first unread message

Ian H

unread,
Jan 11, 2013, 5:28:23 AM1/11/13
to calabash...@googlegroups.com
Hi,

Is it possible on android to scroll_to an element, I don't mean using that exact method but is there a workaround for this?

And example of what I have done using calabash iOS:

scroll_to_row("view:'UITableView'", i)

or

 def scroll_to_(element, dir, limit)
      unless exists(element)
        count = 0
        begin
          scroll("scrollView index:0", dir)
          sleep(STEP_PAUSE)
          count = count + 1
        end while ((not exists(element)) and count < limit.to_i)
      end
    end

I need to do something similar for android but not been successful in this.  Bit cheeky but has anyone else done something like this for android??

Thanks,
Ian

Ian H

unread,
Jan 11, 2013, 9:07:37 AM1/11/13
to calabash...@googlegroups.com
actually, ignore part of the above - what I am seeking is something that tells me that I am at the end of of table, or I have reached the last cell in a table?

If that is not clear then here is another example from my ios tests:
 at_the_bottom = false
    while (!at_the_bottom)
      scroll_table_vew(0, "down")
      displayed_assets = get_view_text('artist')
      assets = assets | displayed_assets.to_a
      at_the_bottom = query("tableViewCell").count == 0
    end

thanks,
Ian

Karl Krukow

unread,
Jan 13, 2013, 8:43:55 AM1/13/13
to calabash...@googlegroups.com
Ian,
I think we can do something with query. Let me take a look at get back.
- Karl

Bo Hauch

unread,
May 22, 2013, 9:32:58 AM5/22/13
to calabash...@googlegroups.com
Are there any answers on this?

I have a test working when I am running on emulator, but failing when on real hardware.
The table is filled in a TableLayout, but I can't see it. When I run the console and ask for all elements (Query "*") I can't see the TableLayout, and I can only see the visible parts of the table (some of them are scrolled out).

So, do there exists an Android counterpart to
    query("tableView","numberOfSections") - which work on iOS.

br
Bo Hauch
Message has been deleted

Shahryar Mozumder

unread,
Jul 31, 2015, 9:19:29 AM7/31/15
to calabash-android, ian.ross...@googlemail.com
Here is what we have been using to find elements in the screen.

# Finds and returns an element in a list even if the element is not on screen.
# You specify the element by the query parameter. The function scrolls down the list the element is found.
# If the element can't be found an empty array is returned
def find_in_list(query_string, list_view="android.widget.ListView")
query_result = query(query_string)
current_screen_state = query('*')
prev_screen_state = []
lv=query(list_view)
while (query_result.empty? and current_screen_state != prev_screen_state)
prev_screen_state = current_screen_state
if lv.empty?
scroll_down
else
scroll(list_view,:down) #perform_action('scroll_down')
end
query_result = query(query_string)
current_screen_state = query('*')
sleep 0.5
end

query_result = query(query_string)
current_screen_state = query('*')
prev_screen_state = []
while (query_result.empty? and current_screen_state != prev_screen_state)
prev_screen_state = current_screen_state
if lv.empty?
scroll_up
else
scroll(list_view,:up) #perform_action('scroll_down')
end
query_result = query(query_string)
current_screen_state = query('*')
sleep 0.5
end

query_result
end
Reply all
Reply to author
Forward
0 new messages