Created
January 27, 2017 15:00
-
-
Save johndavidsimmons/05607da9bab28d4b4d17e855e5b4a80e to your computer and use it in GitHub Desktop.
Setting up the Selenium Chromedriver
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
| from selenium import webdriver | |
| from selenium.webdriver.chrome.options import Options | |
| from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
| import os | |
| def chromeDriver(): | |
| if os.path.exists('.env'): | |
| for line in open('.env'): | |
| var = line.strip().split('=') | |
| if len(var) == 2: | |
| os.environ[var[0]] = var[1] | |
| # Enable JS console Output in terminal | |
| settingsDict = DesiredCapabilities.CHROME | |
| settingsDict['loggingPrefs'] = { 'browser':'ALL' } | |
| # Add dtm debug and omnibug | |
| chrome_options = Options() | |
| chrome_options.add_extension(os.environ['CHROME_DTM_PATH']) | |
| chrome_options.add_extension(os.environ['CHROME_OMNIBUG_PATH']) | |
| # Build the driver object | |
| driver = webdriver.Chrome(os.environ['CHROME_DRIVER_PATH'], chrome_options=chrome_options, desired_capabilities=settingsDict) | |
| return driver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment