2014-04-06 49 views

回答

2

试试这个

将定义添加到ruby步骤文件。

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 

,并从功能文件Then I scroll to cell with "cellMainLabel" label and touch it

+0

感谢它的运作 – Sasha

0

上面的答案看起来有点傻瓜证明比我打电话,但我一直在使用下面的相当愉快:

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 

这两个步骤,第一部分将通过它的id选择微调器,然后第二部分通过你引用的文本选择微调器中的项目。