Reputation: 11
When running cucumber scenarios, I'd like to use Chrome in Incognito mode. I've tried a few suggestions found over the internet, but neither seems to be working.
Currently, I came up to the following, and it starts chrome, but not in incognito mode
Capybara.register_driver :selenium do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => %w["--incognito"]})
Capybara::Selenium::Driver.new(app, {:browser => :chrome, :desired_capabilities => caps})
end
Any tips?
Upvotes: 1
Views: 3407
Reputation: 6934
Digging into the source code, turns out it is very simple:
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome, switches: ['--incognito'])
# or
Capybara::Selenium::Driver.new(app, browser: :chrome, args: ['--incognito'])
end
Upvotes: 7
Reputation: 1
The best way I have found is to add a registry key that every time you open chrome it will open in incognito mode.
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome] "IncognitoModeAvailability"=dword:00000002
If you go to HKLM\SOFTWARE\Policies right click policies add folder "Google" then right click Google and add folder "Chrome." Right click chrome add new dword "IncognitoModeAvailability" set the value to 2.
After you do this Chrome should open in incognito mode everytime.
Upvotes: -1