
Sometimes bandwidth is crucial if you have parallel pipelines for test runs. Think that you have 10 parallel pipes and very pipeline consume bandwidth to complete its tasks, the most heavy part of website generally images. If we disable the images we can fasten the overall test runs. To disable the images you should set the images option to 2 in preferences. For Capybara you can disable the images by following Chrome instance:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Capybara.register_driver :chrome_no_image do |app| | |
preferences = { | |
"profile.managed_default_content_settings.images" => 2, | |
} | |
caps = Selenium::WebDriver::Remote::Capabilities.chrome( | |
'chromeOptions' => { | |
'prefs' => preferences | |
} | |
) | |
Capybara::Selenium::Driver.new(app, {:browser => :chrome, :desired_capabilities => caps}) | |
end |
Sometimes you need to disable popups which intermittently occurs and make your cases flacky. These kind of popups generally controls by another team of the company such instant campaign popups by CRM teams, and etc. To disable the popups, you should set the popups option to 2 in preferences. For Capybara you can disable the popups by following Chrome instance:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Capybara.register_driver :chrome_no_image_popup_maximize do |app| | |
preferences = { | |
"profile.default_content_settings.popups" => 2 | |
} | |
caps = Selenium::WebDriver::Remote::Capabilities.chrome( | |
'chromeOptions' => { | |
'prefs' => preferences | |
} | |
) | |
Capybara::Selenium::Driver.new(app, {:browser => :chrome, :desired_capabilities => caps}) | |
end |
Sometimes you need to make chrome fullscreen for UI related problems. You can set chrome instance as a full-screened view by passing the argument "--start-fullscreen" in args so it will open full page as default by the following Chrome instance. If you want to add more command line arguments you can add it separating by comma "--disable-infobars" this disables the information bars on the top of the page. See the example:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Capybara.register_driver :chrome_fullscreen_noinfobar do |app| | |
args = ["--start-fullscreen", "--disable-infobars" ] | |
Capybara::Selenium::Driver.new(app, {:browser => :chrome, :args => args}) | |
end |
Sure we can use combination of these features together. The important point is that you need to know which features are under preferences and which features are arguments. For maximized windows, disabled images and popups check the following Chrome instance:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara/dsl'; | |
require 'capybara/poltergeist' | |
include Capybara::DSL; | |
require 'selenium-webdriver' | |
Capybara.register_driver :chrome_no_image_popup_maximize do |app| | |
# 2: disable, other than 2 means enable it | |
preferences = { | |
"profile.managed_default_content_settings.images" => 2, | |
"profile.managed_default_content_settings.popups" => 2 | |
} | |
caps = Selenium::WebDriver::Remote::Capabilities.chrome( | |
'chromeOptions' => { | |
'prefs' => preferences, | |
} | |
) | |
args = [ "--start-maximized" ] | |
Capybara::Selenium::Driver.new(app, {:browser => :chrome, :desired_capabilities => caps, :args => args}) | |
end | |
Capybara.default_driver = :chrome_no_image_popup_maximize | |
Capybara.javascript_driver = :chrome_no_image_popup_maximize |
To check whole list of args click this link and the whole list of preferences check this link or see the list of preferences below:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Preferences that are exclusively used to store managed values for default | |
// content settings. | |
const char kManagedDefaultCookiesSetting[] = | |
"profile.managed_default_content_settings.cookies"; | |
const char kManagedDefaultImagesSetting[] = | |
"profile.managed_default_content_settings.images"; | |
const char kManagedDefaultJavaScriptSetting[] = | |
"profile.managed_default_content_settings.javascript"; | |
const char kManagedDefaultPluginsSetting[] = | |
"profile.managed_default_content_settings.plugins"; | |
const char kManagedDefaultPopupsSetting[] = | |
"profile.managed_default_content_settings.popups"; | |
const char kManagedDefaultGeolocationSetting[] = | |
"profile.managed_default_content_settings.geolocation"; | |
const char kManagedDefaultNotificationsSetting[] = | |
"profile.managed_default_content_settings.notifications"; | |
const char kManagedDefaultMediaStreamSetting[] = | |
"profile.managed_default_content_settings.media_stream"; | |
// Preferences that are exclusively used to store managed | |
// content settings patterns. | |
const char kManagedCookiesAllowedForUrls[] = | |
"profile.managed_cookies_allowed_for_urls"; | |
const char kManagedCookiesBlockedForUrls[] = | |
"profile.managed_cookies_blocked_for_urls"; | |
const char kManagedCookiesSessionOnlyForUrls[] = | |
"profile.managed_cookies_sessiononly_for_urls"; | |
const char kManagedImagesAllowedForUrls[] = | |
"profile.managed_images_allowed_for_urls"; | |
const char kManagedImagesBlockedForUrls[] = | |
"profile.managed_images_blocked_for_urls"; | |
const char kManagedJavaScriptAllowedForUrls[] = | |
"profile.managed_javascript_allowed_for_urls"; | |
const char kManagedJavaScriptBlockedForUrls[] = | |
"profile.managed_javascript_blocked_for_urls"; | |
const char kManagedPluginsAllowedForUrls[] = | |
"profile.managed_plugins_allowed_for_urls"; | |
const char kManagedPluginsBlockedForUrls[] = | |
"profile.managed_plugins_blocked_for_urls"; | |
const char kManagedPopupsAllowedForUrls[] = | |
"profile.managed_popups_allowed_for_urls"; | |
const char kManagedPopupsBlockedForUrls[] = | |
"profile.managed_popups_blocked_for_urls"; | |
const char kManagedNotificationsAllowedForUrls[] = | |
"profile.managed_notifications_allowed_for_urls"; | |
const char kManagedNotificationsBlockedForUrls[] = | |
"profile.managed_notifications_blocked_for_urls"; | |
const char kManagedAutoSelectCertificateForUrls[] = | |
"profile.managed_auto_select_certificate_for_urls"; |