Skip to content

Commit

Permalink
Update test_graphs.py
Browse files Browse the repository at this point in the history
- new strategy for headless browser
  • Loading branch information
jrmadsen committed Apr 23, 2024
1 parent 7687342 commit e7978ee
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions source/python/gui/source/tests/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,10 +1518,37 @@ def test_parse_uploaded_file():

def set_up(ip_addr="localhost", ip_port="8051"):
# works for linux, no browser pops up
fireFoxOptions = webdriver.FirefoxOptions()
fireFoxOptions.add_argument("--headless")
browser = webdriver.Firefox(options=fireFoxOptions)
browser.get("http://" + ip_addr + ":" + ip_port + "/")
webdriver_keys = webdriver.__dict__.keys()
browser = None
exception_vals = []

if "Chrome" in webdriver_keys and "ChromeOptions" in webdriver_keys:
try:
chromiumOptions = webdriver.ChromeOptions()
chromiumOptions.add_argument("--headless")
browser = webdriver.Chrome(options=chromiumOptions)
except Exception as e:
exception_vals.append(e)

if (
browser is None
and "Firefox" in webdriver_keys
and "FirefoxOptions" in webdriver_keys
):
try:
fireFoxOptions = webdriver.FirefoxOptions()
fireFoxOptions.add_argument("--headless")
browser = webdriver.Firefox(options=fireFoxOptions)
except Exception as e:
exception_vals.append(e)

if browser:
browser.get("http://" + ip_addr + ":" + ip_port + "/")
elif exception_vals:
for itr in exception_vals:
print(f"Exception: {itr}")
raise exception_vals[0]

return browser


Expand Down

0 comments on commit e7978ee

Please sign in to comment.