-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.py
More file actions
25 lines (21 loc) · 1.02 KB
/
Copy pathbrowser.py
File metadata and controls
25 lines (21 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def create_browser_instance():
chrome_options = Options()
uncached_folder = os.path.join(os.getcwd(), 'uncached', 'chrome-data')
#chrome_options.add_argument("--headless=new")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument(f"--user-data-dir={uncached_folder}")
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
chrome_options.add_experimental_option("detach", True)
try:
return webdriver.Chrome(options=chrome_options)
except Exception as e:
print(f"Failed to create browser instance: {type(e)}")
print(f"Common issues: Ensure previous browser instances are closed")
exit()