verify_translation.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from playwright.sync_api import sync_playwright, expect
  2. import time
  3. def run(playwright):
  4. browser = playwright.chromium.launch(headless=True)
  5. context = browser.new_context()
  6. page = context.new_page()
  7. # Go to the page and wait for it to be ready
  8. page.goto("http://localhost:5173", wait_until="networkidle")
  9. print("Page loaded")
  10. # The aria-label is in Chinese in the source, so we use that.
  11. language_button = page.get_by_role("button", name="切换语言")
  12. # Wait for the button to be visible
  13. expect(language_button).to_be_visible()
  14. print("Language button found")
  15. language_button.click()
  16. print("Language button clicked")
  17. # Click the "Français" option
  18. french_option = page.get_by_role("menuitem", name="Français")
  19. expect(french_option).to_be_visible()
  20. print("French option found")
  21. french_option.click()
  22. print("French option clicked")
  23. # Wait for the language switch to apply
  24. time.sleep(2) # Wait for 2 seconds
  25. # Now the aria-label should be in French
  26. expect(page.get_by_role("button", name="Changer de langue")).to_be_visible(timeout=10000)
  27. print("Language changed to French")
  28. # Take a screenshot to see the page state
  29. page.screenshot(path="jules-scratch/verification/verification.png")
  30. print("Screenshot taken")
  31. browser.close()
  32. with sync_playwright() as playwright:
  33. run(playwright)