Last active
February 20, 2024 02:53
-
-
Save gunesmes/b61ef234ab77832550a981d994b3fb26 to your computer and use it in GitHub Desktop.
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 |
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 |
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 |
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 |
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"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I need a help...About disable geolocation in chromedriver. I used this code, adapting for geolocation, but not it works.
Please could help me.
Here the code..
Capybara.register_driver :chrome do |app|
preferences = {
'profile.default_content_setting_values.geolocation' => '2'
}
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
'chromeOptions' => {
'prefs' => preferences
}
)
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: caps)
end
Capybara.default_driver = :chrome