Skip to content

Commit

Permalink
Basic test working
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackal360 committed Dec 12, 2023
1 parent 29134ec commit 7fe912d
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/example/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/example/static/js/games/Bacterial Culture_elena.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function Bacterial_Culture_start_lab() {
$("#lab_manual").html(
"<div class=\"labmanbubble\">" +
data + "</div>" +
"</br></br><p class=\"modsel\" tabindex=\"0\" " +
"</br></br><p class=\"modsel\" id=\"start_prelab_button\" tabindex=\"0\" " +
"onkeydown=\"handleEnterSpaceClick(event)\"" +
"onclick=\"Bacterial_Culture_start_game()\" >" +
"Start Prelab</p></br></br>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function Temperature_Controller_Part_II_start_lab() {
$("#lab_manual").html(
"<div class=\"labmanbubble\">" +
data + "</div>" +
"</br></br><p class=\"modsel\" tabindex=\"0\" " +
"</br></br><p class=\"modsel\" id=\"start_prelab_button\" tabindex=\"0\" " +
"onkeydown=\"handleEnterSpaceClick(event)\"" +
"onclick=\"Temperature_Controller_Part_II_start_game()\" >" +
"Start Prelab</p></br></br>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function Temperature_Controller_Part_I_start_lab() {
$("#lab_manual").html(
"<div class=\"labmanbubble\">" +
data + "</div>" +
"</br></br><p class=\"modsel\" tabindex=\"0\" " +
"</br></br><p class=\"modsel\" id=\"start_prelab_button\" tabindex=\"0\" " +
"onkeydown=\"handleEnterSpaceClick(event)\"" +
"onclick=\"Temperature_Controller_Part_I_start_game()\" >" +
"Start Prelab</p></br></br>"
Expand Down
2 changes: 1 addition & 1 deletion src/example/templates/elena.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function {{ module_name }}_start_lab() {
$("#lab_manual").html(
"<div class=\"labmanbubble\">" +
data + "</div>" +
"</br></br><p class=\"modsel\" tabindex=\"0\" " +
"</br></br><p class=\"modsel\" id=\"start_prelab_button\" tabindex=\"0\" " +
"onkeydown=\"handleEnterSpaceClick(event)\"" +
"onclick=\"{{ module_name }}_start_game()\" >" +
"Start Prelab</p></br></br>"
Expand Down
2 changes: 1 addition & 1 deletion src/example/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</br>
</br>
{% for fn_module_name,module_name in pick_mod.items() %}
<p class="modsel" tabindex="0" onkeydown="handleEnterSpaceClick(event)" onclick="{{fn_module_name}}_start_lab()">{{module_name}}</p>
<p class="modsel" id="{{fn_module_name}}" tabindex="0" onkeydown="handleEnterSpaceClick(event)" onclick="{{fn_module_name}}_start_lab()">{{module_name}}</p>
</br>
</br>
{% endfor %}
Expand Down
66 changes: 66 additions & 0 deletions src/example/test.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 7fe912d

Please sign in to comment.