Update browser.py
This commit is contained in:
+6
-4
@@ -37,14 +37,16 @@ class Browser:
|
|||||||
chrome_options.add_argument("--disable-gpu")
|
chrome_options.add_argument("--disable-gpu")
|
||||||
chrome_options.add_argument("--no-sandbox")
|
chrome_options.add_argument("--no-sandbox")
|
||||||
chrome_options.add_argument("--disable-dev-shm-usage")
|
chrome_options.add_argument("--disable-dev-shm-usage")
|
||||||
# Automatically install or find ChromeDriver path.(for google chrome and chrome beta).
|
|
||||||
try:
|
chromedriver_path = shutil.which("chromedriver") # system installed driver.
|
||||||
|
|
||||||
|
#If not found, try auto-installing the correct version
|
||||||
|
if not chromedriver_path:
|
||||||
chromedriver_path = chromedriver_autoinstaller.install()
|
chromedriver_path = chromedriver_autoinstaller.install()
|
||||||
except FileNotFoundError as e:
|
|
||||||
chromedriver_path = shutil.which("chromedriver")
|
|
||||||
|
|
||||||
if not chromedriver_path:
|
if not chromedriver_path:
|
||||||
raise FileNotFoundError("ChromeDriver not found. Please install it or add it to your PATH.")
|
raise FileNotFoundError("ChromeDriver not found. Please install it or add it to your PATH.")
|
||||||
|
|
||||||
service = Service(chromedriver_path)
|
service = Service(chromedriver_path)
|
||||||
self.driver = webdriver.Chrome(service=service, options=chrome_options)
|
self.driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||||
self.wait = WebDriverWait(self.driver, 10)
|
self.wait = WebDriverWait(self.driver, 10)
|
||||||
|
|||||||
Reference in New Issue
Block a user