test_e2e_checkout.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import pytest
  2. from playwright.async_api import async_playwright
  3. @pytest.mark.asyncio
  4. async def test_gui_NoPayment():
  5. async with async_playwright() as playwright:
  6. browser = await playwright.chromium.launch(headless=True)
  7. context = await browser.new_context()
  8. page= await context.new_page()
  9. await page.goto("http://localhost:5014/")
  10. await page.get_by_role("link", name="Agorism In The 21st Century -- II ").first.click()
  11. await page.get_by_role("button", name="add to cart").click()
  12. await page.wait_for_timeout(1000)
  13. await page.get_by_role("link", name="The DarkFi eye logo.").click()
  14. await page.get_by_role("link", name="Tshirt 01").click()
  15. await page.get_by_role("group").locator("div").filter(has_text="s").nth(1).click()
  16. await page.get_by_label("s", exact=True).check()
  17. await page.get_by_role("button", name="add to cart").click()
  18. await page.wait_for_timeout(1000)
  19. await page.get_by_role("button", name="add to cart").click()
  20. await page.wait_for_timeout(1000)
  21. await page.get_by_label("Go to Checkout").click()
  22. await page.locator("#price_1PTPnFKMYdpilqPdArvtszSN #button-plus").click()
  23. await page.locator("#prod_RZBk650b1Tx95N").get_by_role("button").nth(1).click()
  24. await page.get_by_placeholder("Email address").click()
  25. await page.get_by_placeholder("Email address").fill("work@andrefincato.info")
  26. await page.get_by_placeholder("Email address").press("Tab")
  27. await page.get_by_placeholder("First name (optional)").fill("<script onerror='alert(\\\\'hax\\\\')'>Dark")
  28. await page.get_by_placeholder("First name (optional)").press("Tab")
  29. await page.get_by_placeholder("Last name").fill("Fi")
  30. await page.get_by_placeholder("Last name").press("Tab")
  31. await page.get_by_placeholder("Address", exact=True).fill("Somewhere 122")
  32. await page.get_by_placeholder("Address", exact=True).press("Tab")
  33. await page.get_by_placeholder("Address No.").fill("42")
  34. await page.get_by_placeholder("Address No.").press("Tab")
  35. await page.get_by_placeholder("Postal code").fill("1225AK")
  36. await page.get_by_placeholder("Postal code").press("Tab")
  37. await page.get_by_placeholder("City").fill("Amsterdam")
  38. await page.get_by_label("Country").select_option("Netherlands")
  39. await page.get_by_placeholder("Additional note (optional)").click()
  40. await page.get_by_placeholder("Additional note (optional)").fill("eef+eifenf\\n\\neineienfeifne+eifenife\\neiufenf\\n\\n...")
  41. await page.get_by_role("button", name="NOW Payments pay button").click()
  42. await page.get_by_role("button", name="Next step").click()
  43. await page.wait_for_timeout(90000)
  44. assert "Thanks for your order." in await page.content()
  45. await context.close()
  46. await browser.close()