-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use common script for headless browser tests
- Loading branch information
Showing
3 changed files
with
50 additions
and
24 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
.github/workflows/scripts/run-wasm-tests-browser-headless.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import logging | ||
import argparse | ||
import sys | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.webdriver.support import expected_conditions as EC | ||
|
||
def run_headless_test(): | ||
parser = argparse.ArgumentParser(description='Run headless browser test.') | ||
parser.add_argument('browser_type', choices=['chrome', 'firefox'], help='Browser type (chrome or firefox)') | ||
args = parser.parse_args() | ||
|
||
if args.browser_type.lower() == 'chrome': | ||
options = webdriver.ChromeOptions() | ||
options.add_argument("--headless=new") | ||
driver = webdriver.Chrome(options=options) | ||
elif args.browser_type.lower() == 'firefox': | ||
options = webdriver.FirefoxOptions() | ||
options.add_argument("--headless") | ||
driver = webdriver.Firefox(options=options) | ||
else: | ||
logging.error("Invalid browser type. Supported types are 'chrome' and 'firefox'.") | ||
return | ||
|
||
try: | ||
driver.get('http://localhost:8080/') | ||
|
||
# Adjust the timeout to 3 minutes | ||
wait = WebDriverWait(driver, 180) | ||
|
||
# Wait until the div with id "tests_finished" is displayed | ||
tests_finished_element = wait.until(EC.presence_of_element_located((By.ID, "tests_finished"))) | ||
|
||
html = driver.page_source | ||
result_file = f"{args.browser_type.lower()}-results.html" | ||
with open(result_file, "w", encoding="utf-8") as file: | ||
file.write(html) | ||
|
||
finally: | ||
driver.quit() | ||
|
||
if __name__ == "__main__": | ||
run_headless_test() |
21 changes: 0 additions & 21 deletions
21
.github/workflows/scripts/run-wasm-tests-firefox-headless.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters