Sim*_*mmo 3 ruby ruby-on-rails cucumber
我在整个黄瓜测试过程中使用了相同的步骤.我想根据调用功能是否分配了标记(在本例中为@javascript)进行微小更改.
是否可以在步骤中测试标签的存在和名称以更改行为?(我意识到我可以创建不同的步骤,但那不是很干吗?)
伪代码解释我在追求什么
When /^I sign in as "(.*)\/(.*)"$/ do |email,password|
step %{I go to the sign in page}
step %{I fill in "user_email" with "#{email}"}
step %{I fill in "user_password" with "#{password}"}
if tag && tag == "@javascript"
step %{I follow "LOG IN"}
else
step %{I press "LOG IN"}
end
end
Run Code Online (Sandbox Code Playgroud)
我通过使用钩子设置变量来解决这个问题,如果您的标记与驱动程序无关,这可能很有用:
Before('@mobile') do
@mobile = true
end
When /^I go to the homepage$/ do
if @mobile
visit "m.mysite.com"
else
visit "www.mysite.com"
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
219 次 |
| 最近记录: |