Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit ce7472f

Browse files
committed
Chore: Add python get_a_chrome_headless_driver() example function
1 parent 100ec73 commit ce7472f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/python_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@
8686
driver = webdriver.Remote(command_executor=myselenium_hub_url, desired_capabilities=caps)
8787
time.sleep(msleep)
8888

89+
def get_a_chrome_headless_driver():
90+
from selenium.webdriver.chrome.options import Options
91+
92+
CHROME_PATH = '/usr/bin/google-chrome-stable'
93+
CHROMEDRIVER_PATH = '/home/user/bin/chromedriver'
94+
WINDOW_SIZE = "1920,1080"
95+
96+
opts = Options()
97+
opts.add_argument("--headless")
98+
opts.add_argument("--window-size=%s" % WINDOW_SIZE)
99+
opts.binary_location = CHROME_PATH
100+
101+
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=opts)
102+
return driver
103+
89104
def is_element_present(how, what):
90105
try: driver.find_element(by=how, value=what)
91106
except NoSuchElementException: return False

0 commit comments

Comments
 (0)