76225

Changing Chrome's settings with Selenium

Question:

I'm working on Chrome with Selenium and I'm looking to change a few settings within Chrome using the webdriver. Using Google and this site, I was able to get most of the settings working. However, a few more seem to escape me and hopefully I can get the answers here. I'm looking to alter the settings before launching the browser, such as using ChromeOptions, rather than using automation to navigate the settings page.

The settings I'm looking to change are as follows:

<ul><li>Disable Javascript</li> <li>Disable the microphone</li> <li>Change the home page</li> <li>Altering the default search engine in the Omnibox </li> </ul>

These 4 are giving me the most issues. Any help?

Answer1:

Perhaps this <a href="http://peter.sh/experiments/chromium-command-line-switches/" rel="nofollow">List of Chromium Command Line Switches</a> will help. E.g.

DesiredCapabilities caps = DesiredCapabilities.chrome(); caps.setCapability("chrome.switches", Arrays.asList("--disable-javascript"));

And

Map<String, Object> preferences = Maps.newHashMap(); preferences.put( "browser.startup.homepage", "http://my.home.page" ); preferences.put( "browser.startup.page", START_WITH_HOME_PAGE ); capabilities.setCapability( ChromeOptions.CAPABILITY, preferences ); ChromeDriver driver = new ChromeDriver( capabilities );

<strong>Update</strong>

My guess is that the following

"import_search_engine": true

from <a href="http://dev.chromium.org/administrators/configuring-other-preferences" rel="nofollow">Configuring other parameters</a> will cause Chrome to ask you to select a search engine when it opens.

Turning off JavaScript makes chrome pretty much a no-op; I do not think that the option is supported. As far as microphones, that is more a system option. A search of about:config for microphone came up empty.

Recommend

  • Openshift: Change the https to http
  • Multiple instances of PHP script won't load concurrently in the same browser from the same URL
  • Bypass blocking of subresource requests whose URLs contain embedded credentials
  • Puppeteer unable to run Chrome on AWS CodeBuild
  • Get css value by CSS and use in Selenium
  • Facebook plugin not works after installing facebook application
  • How can I automatically restart chromium if it crashes?
  • Passing information from command line into Chrome extension
  • HTML5 video fallback when all types unsupported
  • Does the chromeview project need to be built from source before attempting to use cordova-android-ch
  • JS: how can I base64 encode a local file without XMLHttpRequest?
  • Devise auth/sign_in api not returning access-token and client
  • How to clear the icon cache of Chromium browser
  • How make a click on a chromium browser link open in the default browser?
  • Delphi Chromium Embedded - Clear browser cache
  • R sqldf renaming a field in a select statement
  • Available space left on drive - WinAPI - Windows CE
  • Can my PDF ping my server when it is opened?
  • hibernate sets dirty flag (and issues update) even though client did not change value
  • Installing PHP 7 on digitalocean
  • SonarQube: Cannot deactivate rule with missing quality profile
  • SAXReader not re-ecape characters
  • How to generate and display a QR Code in ionic 2
  • How can I set a binding to a Combox in a UserControl?
  • Android full screen on only one activity?
  • Error when parsing timestamp with pandas read_csv
  • Atlas images wrong size on iPad iOS 9
  • Insert into database using onclick function
  • What is Eclipse's Declaration View used for?
  • Spray.io: When (not) to use non-blocking route handling?
  • Accessing IRQ description array within a module and displaying action names
  • Modifying destination and filename of gulp-svg-sprite
  • Can I make an Android app that runs a web view in Chrome 39?
  • GridView Sorting works once only
  • Is there a mandatory requirement to switch app.yaml?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • Turn off referential integrity in Derby? is it possible?
  • Add sale price programmatically to product variations
  • Unable to use reactive element in my shiny app
  • How do I use LINQ to get all the Items that have a particular SubItem?