Calabash android, as clicking a ListView?

有些话、适合烂在心里 提交于 2019-12-11 19:52:40

问题


I've been looking for the answer on the Internet, but could not find it. help me please. How to make pressing the list item in Calabash-Android?


回答1:


Try this out

Add a definition to ruby step file.

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

and call it from feature file Then I scroll to cell with "cellMainLabel" label and touch it




回答2:


The answer above looks a bit more fool proof than mine but I have been using the following quite happily:

spinner selection  

Then (/^I select spinner by id "(.*?)"$/) do |spinnerid|  
   touch("spinner id:'#{spinnerid}'")  
end

select an item in the damn spinner  

Then (/^I touch "(.*?)"$/) do |text|  
    touch("TextView text:'#{text}'")  
end

it's two steps, first part will select the spinner via its id and then the second part selects the item in the spinner via the text you quoted.



来源:https://stackoverflow.com/questions/22891225/calabash-android-as-clicking-a-listview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!