generated from MarketingPipeline/Python-Selenium-Action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Selenium-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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import chromedriver_autoinstaller
from pyvirtualdisplay import Display
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'
]
for option in options:
chrome_options.add_argument(option)
driver = webdriver.Chrome(options = chrome_options)
driver.get('http://github.com')
print(driver.title)
with open('./GitHub_Action_Results.txt', 'w') as f:
f.write(f"This was written with a GitHub action {driver.title}")