Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run selenium without opening a browser in cucumber

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?

like image 315
user731467 Avatar asked Oct 24 '22 13:10

user731467


1 Answers

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:

Capybara.default_driver = :mechanize

If you do need to test JavaScript, then Thoughtbot have just released this helpful gem: https://github.com/thoughtbot/capybara-webkit

like image 111
Andy Waite Avatar answered Oct 27 '22 11:10

Andy Waite