From 7fe912db6110547ef08cce5245b16373f834f249 Mon Sep 17 00:00:00 2001 From: thejackal360 Date: Mon, 11 Dec 2023 17:39:52 -0800 Subject: [PATCH] Basic test working --- src/example/requirements.txt | 7 +- .../js/games/Bacterial Culture_elena.js | 2 +- .../Temperature Controller Part II_elena.js | 2 +- .../Temperature Controller Part I_elena.js | 2 +- src/example/templates/elena.js | 2 +- src/example/templates/index.html | 2 +- src/example/test.py | 66 +++++++++++++++++++ 7 files changed, 75 insertions(+), 8 deletions(-) create mode 100755 src/example/test.py diff --git a/src/example/requirements.txt b/src/example/requirements.txt index 9497d93..02245ad 100644 --- a/src/example/requirements.txt +++ b/src/example/requirements.txt @@ -1,8 +1,9 @@ torchaudio==2.1.1 -torch==2.1.0 -torchvision==0.16.0 +torch +torchvision +selenium -matplotlib==3.3.8 +matplotlib flask==2.0.0 werkzeug==2.2.2 gunicorn==21.2.0 diff --git a/src/example/static/js/games/Bacterial Culture_elena.js b/src/example/static/js/games/Bacterial Culture_elena.js index e272491..2fee8b0 100644 --- a/src/example/static/js/games/Bacterial Culture_elena.js +++ b/src/example/static/js/games/Bacterial Culture_elena.js @@ -111,7 +111,7 @@ function Bacterial_Culture_start_lab() { $("#lab_manual").html( "
" + data + "
" + - "


" + "Start Prelab



" diff --git a/src/example/static/js/games/Temperature Controller Part II_elena.js b/src/example/static/js/games/Temperature Controller Part II_elena.js index dc2f1ed..9a4d188 100644 --- a/src/example/static/js/games/Temperature Controller Part II_elena.js +++ b/src/example/static/js/games/Temperature Controller Part II_elena.js @@ -111,7 +111,7 @@ function Temperature_Controller_Part_II_start_lab() { $("#lab_manual").html( "
" + data + "
" + - "


" + "Start Prelab



" diff --git a/src/example/static/js/games/Temperature Controller Part I_elena.js b/src/example/static/js/games/Temperature Controller Part I_elena.js index 715477c..d092bcf 100644 --- a/src/example/static/js/games/Temperature Controller Part I_elena.js +++ b/src/example/static/js/games/Temperature Controller Part I_elena.js @@ -111,7 +111,7 @@ function Temperature_Controller_Part_I_start_lab() { $("#lab_manual").html( "
" + data + "
" + - "


" + "Start Prelab



" diff --git a/src/example/templates/elena.js b/src/example/templates/elena.js index 0a7ff97..d68b5cf 100644 --- a/src/example/templates/elena.js +++ b/src/example/templates/elena.js @@ -111,7 +111,7 @@ function {{ module_name }}_start_lab() { $("#lab_manual").html( "
" + data + "
" + - "


" + "Start Prelab



" diff --git a/src/example/templates/index.html b/src/example/templates/index.html index 5dc0c67..a7ff988 100644 --- a/src/example/templates/index.html +++ b/src/example/templates/index.html @@ -41,7 +41,7 @@

{% for fn_module_name,module_name in pick_mod.items() %} -

{{module_name}}

+

{{module_name}}



{% endfor %} diff --git a/src/example/test.py b/src/example/test.py new file mode 100755 index 0000000..ca87673 --- /dev/null +++ b/src/example/test.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +from playwright.sync_api import sync_playwright +import subprocess +import time + + +def start_web_server(): + subprocess.run(["python3.10", "app.py", "--local"]) + + +def run_playwright_test(): + with sync_playwright() as p: + # Wait for the server to start (adjust sleep time as needed) + time.sleep(5) + + # Launch a browser and open a new page + browser = p.chromium.launch(headless=False) + context = browser.new_context() + page = context.new_page() + + # Navigate to the web page + print("Loading page...") + page.goto("http://127.0.0.1:5000/") + print("Page loaded!") + page.wait_for_timeout(4000) + + # Find and click on the "Bacterial Culture" bubble + bacterial_culture_bubble = page.locator("p#Bacterial_Culture") + print("Attempting to click 'Bacterial Culture' bubble...") + print(bacterial_culture_bubble) + bacterial_culture_bubble.focus() + page.wait_for_timeout(4000) + page.keyboard.press("Enter") + print("Successfully clicked 'Bacterial Culture'!") + start_prelab_button = page.locator("p#start_prelab_button") + print(start_prelab_button) + page.wait_for_timeout(4000) + start_prelab_button.click(force=True) + print("Successfully clicked 'Start Prelab' button!") + page.wait_for_timeout(15000) + for char in "Joseph": + page.keyboard.press(char) + page.keyboard.press("Enter") + page.wait_for_timeout(10000) + + # Add additional Playwright actions or assertions as needed + + # Close the browser + browser.close() + + +if __name__ == "__main__": + import multiprocessing + + # Start the web server in a separate process + web_server_process = multiprocessing.Process(target=start_web_server) + web_server_process.start() + + try: + # Run the Playwright test in the main process + run_playwright_test() + finally: + # Stop the web server process when the test is done + web_server_process.terminate() + web_server_process.join()