-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.py
More file actions
26 lines (18 loc) · 841 Bytes
/
driver.py
File metadata and controls
26 lines (18 loc) · 841 Bytes
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
26
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
def chrome_options() -> webdriver.ChromeOptions:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("--headless")
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('useAutomationExtension', False)
return chrome_options
def chrome_browser(wait: int = 5) -> webdriver.Chrome:
driver = webdriver.Chrome(
service=Service('/var/task/chromedriver'),
options=chrome_options()
)
driver.implicitly_wait(wait)
return driver