You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.5 KiB
29 lines
1.5 KiB
4 years ago
|
# Init Chrome web driver with extensions (if applicable)
|
||
|
# Import section
|
||
|
from selenium import webdriver
|
||
|
|
||
|
##########################
|
||
|
# Init the Chrome web driver
|
||
|
###########################
|
||
|
gChromeExeFullPath = r'..\Resources\GoogleChromePortable\GoogleChromePortable.exe'
|
||
|
gExtensionFullPathList = []
|
||
|
gWebDriverFullPath = r'..\Resources\SeleniumWebDrivers\Chrome\chromedriver_win32 v84.0.4147.30\chromedriver.exe'
|
||
|
def WebDriverInit(inWebDriverFullPath, inChromeExeFullPath, inExtensionFullPathList):
|
||
|
# Set full path to exe of the chrome
|
||
|
lWebDriverChromeOptionsInstance = webdriver.ChromeOptions()
|
||
|
lWebDriverChromeOptionsInstance.binary_location = inChromeExeFullPath
|
||
|
# Add extensions
|
||
|
for lExtensionItemFullPath in inExtensionFullPathList:
|
||
|
lWebDriverChromeOptionsInstance.add_extension (lExtensionItemFullPath)
|
||
|
# Run chrome instance
|
||
|
lWebDriverInstance = None
|
||
|
if inWebDriverFullPath:
|
||
|
# Run with specified web driver path
|
||
|
lWebDriverInstance = webdriver.Chrome(executable_path = inWebDriverFullPath, chrome_options=lWebDriverChromeOptionsInstance)
|
||
|
else:
|
||
|
lWebDriverInstance = webdriver.Chrome(chrome_options = lWebDriverChromeOptionsInstance)
|
||
|
# Return the result
|
||
|
return lWebDriverInstance
|
||
|
|
||
|
# Инициализировать Google Chrome with selenium web driver
|
||
|
lWebDriver = WebDriverInit(inWebDriverFullPath = gWebDriverFullPath, inChromeExeFullPath = gChromeExeFullPath, inExtensionFullPathList = gExtensionFullPathList)
|