无需在 Cucumber 中打开浏览器即可运行 selenium
我有一个关于在黄瓜中使用硒的问题。
这是黄瓜的功能:
@selenium @javascript
Scenario: Create forum
Given I have a site named "hairclub" and I logged in as admin
When I am on the "admin" page
要运行,我使用这个命令:
cucumber features/forum.feature
它工作正常;它会打开浏览器(如您所见 @selenium @javascript 标记
)。一切看起来都不错。
我想运行相同的黄瓜脚本但不打开浏览器;我想如果场景扩大,浏览器运行将需要一段时间。我希望能够在打开浏览器的情况下运行,也希望在不打开浏览器的情况下运行。有什么命令可以从终端传递它来覆盖 @selenium @javascript
吗?
I have a question about using selenium in cucumber.
here is the cucumber features:
@selenium @javascript
Scenario: Create forum
Given I have a site named "hairclub" and I logged in as admin
When I am on the "admin" page
To run, I use this command:
cucumber features/forum.feature
It works fine; it opens the browser (as you can see @selenium @javascript tag
). Everything looks good.
I want to run the same cucumber script but not open the browser; I imagine if the scenario grows it will take a while to run with the browser. I want both the capability to run with browser open and also without browser opening. Is there any command I can pass it from terminal to overwrite @selenium @javascript
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有浏览器就无法运行 Selenium,因为 Selenium 是通过控制浏览器来工作的。
但是,您可以在不使用 Selenium 的情况下运行 Cucumber 功能。
如果场景不需要 JavaScript,那么您可以使用 mechanize:
如果您确实需要测试 JavaScript,那么 Thoughtbot 刚刚发布了这个有用的 gem:https://github.com/thoughtbot/capybara-webkit
You can't run Selenium without a browser, because Selenium works by controlling the browser.
However, you can run Cucumber features without using Selenium.
If the scenario doesn't require JavaScript then you can use mechanize:
If you do need to test JavaScript, then Thoughtbot have just released this helpful gem: https://github.com/thoughtbot/capybara-webkit