Skip to content

Commit

Permalink
Clean up the code
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackal360 committed Dec 12, 2023
1 parent 7fe912d commit 745af7d
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/example/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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.")

0 comments on commit 745af7d

Please sign in to comment.