Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
chromedriver intl.accept_languages pass as chrome options
# This work with selenium
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from splinter.driver.webdriver import BaseWebDriver, WebDriverElement
options = Options()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
browser = BaseWebDriver()
browser.driver = Chrome(chrome_options=options)
browser.visit('http://example.com')
# With splinter there is 2 options :
# Splinter API only
from splinter import Browser
from splinter.driver.webdriver.chrome import Options
options = Options()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
browser = Browser('chrome', options=options)
browser.visit('http://example.com')
# Splinter and selenium API
from splinter import Browser
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
browser = Browser('chrome', options=options)
browser.visit('http://example.com')
@BuhtigithuB

This comment has been minimized.

Copy link
Owner Author

commented Apr 27, 2017

Importing ChromeOptions() from selenium appear a little bit faster :

import timeit
In [36]: timeit.timeit('''
...: from splinter import Browser
...: from selenium import webdriver
...: options = webdriver.ChromeOptions()
...: ''', number=100000)
Out[36]: 0.292525053024292

In [38]: timeit.timeit('''
...: from splinter import Browser
...: from splinter.driver.webdriver.chrome import Options
...: options = Options()
...: ''', number=100000)
Out[38]: 0.32404208183288574

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.