Search code examples
bddcalabashcalabash-android

Touch each custom ListView item with calabash-android


So I try to touch an custom ListView item to see next View and then I want to move back but right now I'm not able to query any of my list item.

My gherkin code is:

Then I choose category:
        | Artystyczne |
        | Językowe  |
        | Komputery i robotyka  |
        | Korepetycje |
        | Medyczne  |
        | Praktyczno-techniczne |
        | Rozrywkowe  |
        | Rozwijające |
        | Sportowe  |
        | Taneczne  |
        | Pozostałe |

and in my step looks like:

Then(/^I choose category:$/) do |table|
  # table is a Cucumber::Ast::Table
  data = table.raw
  data.each do |i|
    #tap_mark i
    #tap_when_element_exists("* {text CONTAINS[c] '#{i}'}")
    touch(i)
    #TODO move back one View
  end
end

when I run test the error says:

Then I choose category:                       # features/step_definitions/calabash_steps.rb:25
      | Artystyczne           |
      | JÄtzykowe              |
      | Komputery i robotyka  |
      | Korepetycje           |
      | Medyczne              |
      | Praktyczno-techniczne |
      | Rozrywkowe            |
      | RozwijajÄce           |
      | Sportowe              |
      | Taneczne              |
      | PozostaĹ'e             |
      Failed to perform gesture. java.util.ArrayList cannot be cast to java.lang.String (RuntimeError)
      ./features/step_definitions/calabash_steps.rb:31:in `block (2 levels) in <top (required)>'
      ./features/step_definitions/calabash_steps.rb:28:in `each'
      ./features/step_definitions/calabash_steps.rb:28:in `/^I choose category:$/'
      features\my_first.feature:11:in `Then I choose category:'

I've tried to do some debug in calabash-android console and funny thing is that tap_mark "Artystyczne" is working perfectly. So I assume that there is something wrong with my Data Tables but can't figure (or google) what. I would appreciate any help :)

Have a nice day :)

Steps definitions

Features


Solution

  • Then(/^I choose category:$/) do |table|   
     data = table.raw
                data.each do |identifiers|
                    identifiers.each do |identifier|
                        tap_when_element_exists("* {text CONTAINS[c] '#{identifier}'}")
                        sleep(1)
                    end
                end
    

    You got assoc array here u need 2 each loops ;)