test_e2e_checkout.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import re
  2. from playwright.sync_api import Playwright, sync_playwright, expect
  3. def run(playwright: Playwright) -> None:
  4. browser = playwright.chromium.launch(headless=False)
  5. context = browser.new_context()
  6. page = context.new_page()
  7. page.goto("http://localhost:5014/")
  8. page.get_by_role("link", name="Cap 01 30CHF").click()
  9. page.get_by_role("button", name="add to cart").click()
  10. page.get_by_role("link", name="The DarkFi eye logo. A white").click()
  11. page.get_by_role("link", name="Tshirt “hardware” 35CHF").click()
  12. page.get_by_role("group").locator("div").filter(has_text="s").nth(1).click()
  13. page.get_by_label("black").check()
  14. page.get_by_label("s", exact=True).check()
  15. page.get_by_role("button", name="add to cart").click()
  16. page.get_by_role("button", name="add to cart").click()
  17. page.get_by_label("Go to Checkout").click()
  18. page.locator("#price_1PTPnFKMYdpilqPdArvtszSN #button-plus").click()
  19. page.locator("#price_1PZCznKMYdpilqPduNMHsUiY").get_by_role("button").nth(1).click()
  20. page.get_by_placeholder("Email address").click()
  21. page.get_by_placeholder("Email address").fill("work@andrefincato.info")
  22. page.get_by_placeholder("Email address").press("Tab")
  23. page.get_by_placeholder("First name (optional)").fill("<script onerror='alert(\\\\'hax\\\\')'>Dark")
  24. page.get_by_placeholder("First name (optional)").press("Tab")
  25. page.get_by_placeholder("Last name").fill("Fi")
  26. page.get_by_placeholder("Last name").press("Tab")
  27. page.get_by_placeholder("Address", exact=True).fill("Somewhere 122")
  28. page.get_by_placeholder("Address", exact=True).press("Tab")
  29. page.get_by_placeholder("Apartment, suite, etc. (").press("Tab")
  30. page.get_by_placeholder("Postal code").fill("1225AK")
  31. page.get_by_placeholder("Postal code").press("Tab")
  32. page.get_by_placeholder("City").fill("Amsterdam")
  33. page.get_by_label("Country").select_option("Netherlands")
  34. page.get_by_placeholder("Additional note (optional)").click()
  35. page.get_by_placeholder("Additional note (optional)").fill("eef+eifenf\\n\\neineienfeifne+eifenife\\neiufenf\\n\\n...")
  36. page.get_by_role("button", name="Stripe pay button").click()
  37. page.get_by_placeholder("1234 1234 1234").click()
  38. page.get_by_placeholder("1234 1234 1234").fill("4242 4242 4242 42422")
  39. page.get_by_placeholder("1234 1234 1234").press("Tab")
  40. page.get_by_placeholder("MM / YY").fill("05 / 29")
  41. page.get_by_placeholder("MM / YY").press("Tab")
  42. page.get_by_placeholder("CVC").fill("1111")
  43. page.get_by_placeholder("CVC").press("Tab")
  44. page.get_by_placeholder("Full name on card").fill("Fi")
  45. page.get_by_test_id("hosted-payment-submit-button").click()
  46. page.goto("http://localhost:5014/checkout/success")
  47. # ---------------------
  48. context.close()
  49. browser.close()
  50. with sync_playwright() as playwright:
  51. run(playwright)