我目前正在使用calabash-android为我的Android应用程序编写测试脚本。我面临的一个问题是,我并不总是知道应用程序应该走哪条路。
例如,如果我打开一个作业,该作业可能会抛出一个警告,要求您确认要在显示下一个“作业”活动之前打开该作业,但是其他作业可能不会显示此警告。
我需要的是一种在我的cucumber代码中使用if/else语句分析特定视图的方法。以前有没有人能做到这一点?
下面是我想要的一个例子:
Scenario: As a valid user I can log into my app and view my jobs list
When I see "Log In"
Then I enter text "JoeBloggs" into field with id "txtUsername"
Then I enter text "Password123" into field with id "txtPassword"
Then I press "Log In"
And I wait
Then I see "Welcome To The Your Application"
Then I press "Jobs"
And I wait
Then I see "Back"
Then I see "Job Number"
Then I press list item number 2
And I wait
Then I see "Amey Reference"
Then I press view with id "btnStartJob"
And I wait
If I see "Warning" then press "Okay" else I should see "Job Detail"发布于 2015-06-25 20:31:17
我刚刚对此进行了适当的思考,并意识到我可以在这里做一个“给定”。下面是一个示例:
Given that I see "Wrong Device Detected!"
Then I press "Yes"在我的calabash步骤中,我定义了这个步骤:
Given /^that I see "([^\"]*)"$/ do |text|
query("* text:'#{text}'")[0]
endhttps://stackoverflow.com/questions/31049578
复制相似问题