-
Notifications
You must be signed in to change notification settings - Fork 11
/
simplebrowsertest.py
executable file
·47 lines (38 loc) · 1.21 KB
/
simplebrowsertest.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
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
TEST_URL = "https://www.artefactual.com"
TEST_TITLE = "Home | Artefactual"
def get_chrome_driver():
options = webdriver.ChromeOptions()
options.add_argument("--headless=old")
driver = webdriver.Chrome(options=options)
return driver
def get_firefox_driver():
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
return driver
def run_test(driver_getter, name):
print(f"{name}... ", end="")
try:
driver = driver_getter()
except WebDriverException as err:
print("error!", err)
return 1
try:
driver.get(TEST_URL)
assert driver.title == TEST_TITLE
print("success!")
print("Capabilities:", driver.capabilities)
except Exception as err:
print("error!", err)
return 1
finally:
driver.quit()
return 0
if __name__ == "__main__":
print("Starting tests...")
chrome_result = run_test(get_chrome_driver, "Chrome")
firefox_result = run_test(get_firefox_driver, "Firefox")
exit(chrome_result or firefox_result)