Disabling Selenium Chrome Automation Banner, Save address?, Save card?, Save password?, and Change your password Pop-Ups
Image: Pencil Sharpener by Wendy Bayer
This shows you how to disable those Chrome Save address?, Save card?, Save Password?, and Change your password pop-up windows in Selenium Webdriver projects.
It also shows you how to disable the Chrome is being controlled by automated test software banner.
Besides being distracting, these may shift or cover other elements.
This example is specifically in Ruby RSpec Capybara, but the cited links may have alternative implementations.
This post also includes a sample test project that demonstrates disabling the automation banner and Save address?, Save Password?, and Change your password pop-ups. I do not have a test/fake endpoint for entering a credit card.
In order to change Chrome behavior like disabling the automation
banner and pop-ups, you will have to create Selenium Chrome
Options in your language's
Selenium Webdriver bindings.
In the Capybara browser automation framework using Selenium Webdriver, it looks like this...
chrome_options = ::Selenium::WebDriver::Chrome::Options.new()Previously, the Chrome is being controlled by automated test software banner was disabled by adding the Chrome argument
chrome_options.add_argument('--disable-infobars')
Here you have to exclude the switch "enable-automation"...
chrome_options = ::Selenium::WebDriver::Chrome::Options.new()
chrome_options.exclude_switches << "enable-automation"π‘οΈ Strangely enough, when this automation banner is disabled, I found that the Chrome Save password? pop-up started appearing where it did not before. The sample demonstration project should show this on the login page.
π Here is a reference on the deprecation of
--disable-infobarsin this StackExchange post
The Chrome Save ? pop-ups are all disabled the same way by
adding preferences to the Chrome Option.
chrome_options = ::Selenium::WebDriver::Chrome::Options.new()
# Disable Chrome's "Save address?" pop-up
chrome_options.add_preference("autofill.profile_enabled", false)π Here my original reference was in C# Selenium in this Stack Overflow post
chrome_options = ::Selenium::WebDriver::Chrome::Options.new()
# Disable Chrome's "Save password?" pop-up
chrome_options.add_preference("credentials_enable_service", false)
chrome_options.add_preference("profile.password_manager_enabled", false)π Here my original reference was in Ruby Watir Selenium in this Stack Overflow post
chrome_options = ::Selenium::WebDriver::Chrome::Options.new()
# Disable Chrome's "Save card?" pop-up
chrome_options.add_preference("autofill.credit_card_enabled", false)This one was tricky and somehow I stumbled across this Chrome Check In which led me to the preference name
This disables the Change your password - The password you just used was found in a data breach. Google Password Manager recommends changing your password now pop-up.
chrome_options = ::Selenium::WebDriver::Chrome::Options.new()
# Disable Chrome's "Change your password" pop-up"
chrome_options.add_preference('profile.password_manager_leak_detection', false)π Here my original reference was in this Stack Overflow post which also shows an example for Java
Here is a complete example of creating and configuring a Selenium Webdriver Chrome Browser with the automation banner, Save ?, and Change your password pop-ups disabled.
# Create Chrome options
chrome_options = ::Selenium::WebDriver::Chrome::Options.new()
# Disable the "Chrome is being controlled by automated test software" banner
chrome_options.exclude_switches << "enable-automation"
# Disable Chrome's "Save address?" pop-up
chrome_options.add_preference("autofill.profile_enabled", false)
# Disable Chrome's "Save password?" pop-up
chrome_options.add_preference("credentials_enable_service", false)
chrome_options.add_preference("profile.password_manager_enabled", false)
# Disable Chrome's "Save card?" pop-up
chrome_options.add_preference("autofill.credit_card_enabled", false)
# Disable Chrome's "Change your password" pop-up"
chrome_options.add_preference('profile.password_manager_leak_detection', false)
# Use the options by registering the driver
Capybara.register_driver :chrome_browser do |app|
Capybara::Selenium::Driver.new(app,
browser: :chrome,
options: chrome_options)
end
Capybara.default_driver = :chrome_browserYou should be able to see the disabling of the Chrome automation
banner, Save ? , and Change your password pop-ups with this
demonstration Capybara RSpec project. The tests use sleep statements
giving you time to view the page with or without the banner and pop-ups.
It includes two Capybara Selenium Chrome tests. One that fills in an address and one that fills in a user name and password. The tests run three times.
The first time the tests run should show the automation banner, the
Save address?, and Change your password pop-ups. This is using the Capybara-defined :selenium_chrome driver which is mostly Chrome defaults.
The second time they run, it should show that the automation banner is gone but the Save password? pop-up now appears. This is using a user-defined Capybara driver with the automation banner disabled.
Finally, the third time the tests run should show no automation banner, no Save ?, and no Change your password pop-ups. This is using a user-defined Capybara driver with the automation banner and the pop-ups disabled.
You will build the RSpec Selenium Capybara project yourself and use the code included here.
You must have a functioning Ruby environment with Chrome installed
- Install the
rspecgemgem install rspec
Here you create a new RSpec project called demo.
-
Make a
demodirectorymkdir demo
-
Change directory to your
demodirectorycd demo -
Install the
rspecgemgem install rspec
-
Initialize a project with RSpec
rspec --init
All file paths shown are relative to the
project root (i.e. demo) directory.
In Gemfile...
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'capybara'
gem 'rspec'
gem 'selenium-webdriver'In .rspec...
--require spec_helper
--format documentation
--colorThis is the demonstration with the two tests (shared_examples) that run
three times using different Capybara driver configurations.
First you need to create the
spec/features directory in your project...
- Create the
spec/featuresdirectory
mkdir -p spec/featuresThen in file spec/features/demonstrate_disable_banner_and_save_popups_spec.rb...
# frozen_string_literal: true
require 'capybara/rspec'
require 'selenium/webdriver'
RSpec.shared_examples 'Banner and Chrome pop-up situations' do
it 'Fills in an address' do
visit 'https://parabank.parasoft.com/parabank/register.htm'
within('#customerForm') do
fill_in 'customer.firstName', with: 'Bob'
fill_in 'customer.lastName', with: 'Dobbs'
fill_in 'customer.address.street', with: '123 Dobbstown Rd.'
fill_in 'customer.address.city', with: 'Dobbstown'
fill_in 'customer.address.state', with: 'Iowa'
fill_in 'customer.address.zipCode', with: '43435'
fill_in 'customer.ssn', with: '123-45-6789'
fill_in 'customer.username', with: 'bobdobbs'
fill_in 'customer.password', with: '1234567890'
fill_in 'repeatedPassword', with: '1234567890'
click_button 'Register'
end
# Allow to time to observe the behavior
sleep 8
end
it 'Fills in a username and password' do
visit 'https://the-internet.herokuapp.com/login'
fill_in 'username', with: 'tomsmith'
fill_in 'password', with: 'SuperSecretPassword!'
click_button 'Login'
# Allow to time to observe the behavior
sleep 9
end
end
describe 'Demonstrating Disabling Chrome Banner and Pop-ups' do
after do
# Quit browser (session) to not cache the registered driver
Capybara.current_session.quit
end
describe 'when nothing is disabled, there is a banner and pop-ups', type: :feature do
before :each do
# --- Default Capybara Chrome ---
Capybara.default_driver = :selenium_chrome
end
include_examples 'Banner and Chrome pop-up situations'
end
describe 'when just banner is disabled, Save password? now appears', type: :feature do
before :each do
# --- Registering your own chrome with options to disable banner ---
# Create Chrome options
chrome_options = ::Selenium::WebDriver::Chrome::Options.new
# Disable the "Chrome is being controlled by automated test software" banner
chrome_options.exclude_switches << 'enable-automation'
# Use the options by registering the driver
Capybara.register_driver :capy_browser do |app|
Capybara::Selenium::Driver.new(app,
browser: :chrome,
options: chrome_options)
end
Capybara.default_driver = :capy_browser
end
include_examples 'Banner and Chrome pop-up situations'
end
describe 'when banner and pop-ups are all disabled', type: :feature do
before :each do
# --- Registering your own chrome with options to disable banner and Save pop-ups---
# Create Chrome options
chrome_options = ::Selenium::WebDriver::Chrome::Options.new
# Disable the "Chrome is being controlled by automated test software" banner
chrome_options.exclude_switches << 'enable-automation'
# Disable Chrome's "Save address?" pop-up
chrome_options.add_preference('autofill.profile_enabled', false)
# Disable Chrome's "Save password?" pop-up
chrome_options.add_preference('credentials_enable_service', false)
chrome_options.add_preference('profile.password_manager_enabled', false)
# Disable Chrome's "Save card?" pop-up
chrome_options.add_preference('autofill.credit_card_enabled', false)
# Disable Chrome's "Change your password" pop-up"
chrome_options.add_preference('profile.password_manager_leak_detection', false)
# Use the options by registering the driver
Capybara.register_driver :chrome_browser do |app|
Capybara::Selenium::Driver.new(app,
browser: :chrome,
options: chrome_options)
end
Capybara.default_driver = :chrome_browser
end
include_examples 'Banner and Chrome pop-up situations'
end
endTo build and run the demonstration...
-
Build the project
bundle install -
Run the demonstration
bundle exec rspec
You should see the tests run three different times demonstrating disabling the automation banner, Save ?, and Change your password pop-ups.
Thank you so much for writing this!