Calabash Android Looping via ListView for validation

I just started using Calabash and looked through the list.

For each line of the list, I want to check for some representation of text and image.

However, I'm not sure how I can scroll through the list?

Sort of

 foreach list_item in listview check text label with id check image view with id end 

Any help would be appreciated.

+1
source share
3 answers

I'm not sure about using foreach in this case, but you can do this based on the index number in the list. Something like getting the number of elements, then iterates through them in a loop using two parameters

 getListView().setSelection(21); 

For smooth scrolling:

 getListView().smoothScrollToPosition(21); 

From this post fooobar.com/questions/45712 / ... HandlerExploit

And then for each item, check the image and text.

+1
source

I used this in my project and it works, I hope it helps you.

In your scenario:

Then I scroll through the text labeled β€œxyz” and touch it

Declare the step as follows:

 Then /^I scroll to text with "([^\"]*)" label and touch it$/ do |name| element="TextView text:'#{name}'" if !element_exists(element) wait_poll(timeout: 20, timeout_message: 'Unable to find "Example"', :until_exists => "TextView text:'#{name}'") do scroll_down end if element_exists(element) touch element sleep(10) else screenshot_and_raise "could not find the cell" end else touch element sleep(10) end end 
0
source

@ userMod2 Check below solutions -

  • Solution 1

When you use

myList.getAdapter (). GetView (me, NULL, NULL)

you get a new instance of the item view, try

ListView.getChildAt (position)

method like this

  private void ButtonClick() { /** get all values of the EditText-Fields */ View v; ArrayList<String> mannschaftsnamen = new ArrayList<String>(); EditText et; for (int i = 0; i < myList.getCount(); i++) { v = myList.getAdapter().getView(i, null, null); et = (EditText) v.findViewById(i); mannschaftsnamen.add(et.getText().toString()); } // Add your action code here // Add your action code here } 
  • Decision 2

     public void onScroll(AbsListView v, int firstVisibleItem, int visibleCount, int totalItemCount) { ListView lv = this.getListView(); int childCount = lv.getChildCount(); for (int i = 0; i < childCount; i++) { View v = lv.getChildAt(i); TextView tx = (TextView) v.findViewById(R.id.mytext); tx.setTextSize(textSize); } } 
0
source

Source: https://habr.com/ru/post/944999/


All Articles