If you need to test the Chrome browser with certain browser options, you can useChromeOptions to customize browser settings for your tests. You can find more information on the official Chrome website. This article includes some examples of customizations that you may find useful.
Default Chrome Browser Settings Used by Sauce Labs
By default, Sauce Labs uses a set of default ChromeOptions. If you use custom options, those defaults will be entirely overriden. It's important to retain these default options for your tests to work properly, so if you want to use custom options, you will also want to include these options that Sauce normally provides:
"args": [ "start-maximized", "disable-infobars", |
Example Chrome Browser Settings
Setting Browser Language
DesiredCapabilities caps = new DesiredCapabilities(); ChromeOptions options = new ChromeOptions(); options.addArguments("--lang=es"); -> Changing the language to spanish caps.setCapability(ChromeOptions.CAPABILITY, options); |
Forcing Chrome to Allow Push Notifications
DesiredCapabilities caps = new DesiredCapabilities(); ChromeOptions options = new ChromeOptions(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("profile.default_content_settings.popups", 0); prefs.put("profile.default_content_setting_values.notifications", 1); options.setExperimentalOption("prefs", prefs); caps.setCapability(ChromeOptions.CAPABILITY, options); |