- Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathSelenium-Template.py
40 lines (32 loc) · 1.21 KB
/
Selenium-Template.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
fromseleniumimportwebdriver
fromselenium.webdriver.chrome.optionsimportOptions
fromselenium.webdriver.chrome.serviceimportService
importchromedriver_autoinstaller
frompyvirtualdisplayimportDisplay
display=Display(visible=0, size=(800, 800))
display.start()
chromedriver_autoinstaller.install() # Check if the current version of chromedriver exists
# and if it doesn't exist, download it automatically,
# then add chromedriver to path
chrome_options=webdriver.ChromeOptions()
# Add your options as needed
options= [
# Define window size here
"--window-size=1200,1200",
"--ignore-certificate-errors"
#"--headless",
#"--disable-gpu",
#"--window-size=1920,1200",
#"--ignore-certificate-errors",
#"--disable-extensions",
#"--no-sandbox",
#"--disable-dev-shm-usage",
#'--remote-debugging-port=9222'
]
foroptioninoptions:
chrome_options.add_argument(option)
driver=webdriver.Chrome(options=chrome_options)
driver.get('http://github.com')
print(driver.title)
withopen('./GitHub_Action_Results.txt', 'w') asf:
f.write(f"This was written with a GitHub action {driver.title}")