From 745af7d5bbf0ccd825bb24535fcbe2881a5ec7d1 Mon Sep 17 00:00:00 2001 From: thejackal360 Date: Mon, 11 Dec 2023 17:42:36 -0800 Subject: [PATCH] Clean up the code --- src/example/test.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/example/test.py b/src/example/test.py index ca87673..d7e7967 100755 --- a/src/example/test.py +++ b/src/example/test.py @@ -10,43 +10,54 @@ def start_web_server(): def run_playwright_test(): - with sync_playwright() as p: - # Wait for the server to start (adjust sleep time as needed) - time.sleep(5) + # Step 1: Start the web server + print("Step 1: Starting web server...") + start_web_server() + + # Step 2: Wait for the server to start (adjust sleep time as needed) + print("Step 2: Waiting for the server to start...") + time.sleep(5) - # Launch a browser and open a new page + # Step 3: Launch a browser and open a new page + print("Step 3: Launching browser and opening a new page...") + with sync_playwright() as p: browser = p.chromium.launch(headless=False) context = browser.new_context() page = context.new_page() - # Navigate to the web page - print("Loading page...") + # Step 4: Navigate to the web page + print("Step 4: Navigating to the web 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 + # Step 5: 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) + print("Step 5: Clicking 'Bacterial Culture' bubble...") bacterial_culture_bubble.focus() page.wait_for_timeout(4000) page.keyboard.press("Enter") print("Successfully clicked 'Bacterial Culture'!") + + # Step 6: Find and click on the "Start Prelab" button start_prelab_button = page.locator("p#start_prelab_button") - print(start_prelab_button) + print("Step 6: Clicking '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) + + # Step 7: Type "Joseph" as the user's name and press Enter + print("Step 7: Typing 'Joseph' and pressing Enter...") 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 + # Step 8: Add additional Playwright actions or assertions as needed - # Close the browser + # Step 9: Close the browser + print("Step 9: Closing the browser...") browser.close() @@ -61,6 +72,8 @@ def run_playwright_test(): # Run the Playwright test in the main process run_playwright_test() finally: - # Stop the web server process when the test is done + # Step 10: Stop the web server process when the test is done + print("Step 10: Stopping web server process...") web_server_process.terminate() web_server_process.join() + print("Test complete.")