gpt4 book ai didi

ruby-on-rails - 如何在Capybara中更改 cucumber 默认测试的默认驱动程序?

转载 作者:行者123 更新时间:2023-12-03 09:27:38 25 4
gpt4 key购买 nike

Capybara提供的文档中,您可以在特定的测试组上更改default_driver:

describe 'some stuff which requires js', :js => true do
it 'will use the default js driver'
it 'will switch to one specific driver', :driver => :selenium
end

如果我想对特定的 cucumber 测试组进行此操作怎么办?如何添加这些参数?
When /^I do something$/  do
fill_in "a_text_box", :with => "stuff"
fill_in "another_text_box", :with => "another_thing"
end

谢谢!

最佳答案

在 cucumber 中,我分两个步骤完成了此操作:

/features/support/env.rb中,放置以下行:

Capybara.javascript_driver = :webkit

然后在 cucumber 功能中,在特定方案之前,在方案之前添加 @javascript,如下所示:
@javascript
Scenario: Successful sign in - with no flash message if using current firefox
When I'm using a current version of Firefox
When I visit the practitioner home page with "jane.doe@example.com"'s token
Then I should be signed in as practitioner "Jane Doe"
And I should be on the practitioner activities welcome page
And I should not see a flash message warning me I have an unsupported browser

这告诉 cucumber 在运行特定场景时使用 javascript驱动程序。

这就是我使用Capybara Webkit完成此操作的方式-我确定其他驱动程序也是如此。

关于ruby-on-rails - 如何在Capybara中更改 cucumber 默认测试的默认驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10508741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com