Compare commits

..

No commits in common. "64e7ea653e04e8a5eae29bd603e2f837de4f9344" and "9cd6e6b9e33626336a3d7b7f0bda6fe03b4104d8" have entirely different histories.

2 changed files with 21 additions and 21 deletions

3
.gitignore vendored
View file

@ -1,3 +0,0 @@
__pycache__
.mypy_cache
run.fcgi

View file

@ -1,8 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
import re from datetime import datetime, date
from datetime import date, datetime
from playwright.sync_api import Playwright, Request, expect, sync_playwright from playwright.sync_api import Playwright, Request, expect, sync_playwright
@ -55,27 +54,29 @@ def run(playwright: Playwright) -> None:
context = browser.new_context() context = browser.new_context()
page = context.new_page() page = context.new_page()
hr = HandleResponse() # hr = HandleResponse()
page.on("requestfinished", hr.requestfinished) # page.on("requestfinished", hr.requestfinished)
re_month_name = re.compile(r"^([A-Z][a-z]+) (\d{4})$")
page.goto("https://www.eurotunnel.com/uk/") page.goto("https://www.eurotunnel.com/uk/")
page.get_by_role("button", name="Accept All Cookies").click() page.get_by_role("button", name="Accept All Cookies").click()
page.get_by_role("textbox", name="Outbound").click() page.get_by_role("textbox", name="Outbound").click()
month_row = page.get_by_role("row", name=re_month_name)
month_and_year = month_row.inner_text().strip() month = page.locator("div.ui-datepicker-month").first
if month_and_year == "August 2023": print(month)
month_row.get_by_role("cell").nth(1).click() print(month.text_content())
else:
assert month_and_year == "September 2023" page.close()
context.close()
browser.close()
return
page.get_by_role("row", name="August 2023").get_by_role("cell").nth(1).click()
page.get_by_role("cell", name="29").click() page.get_by_role("cell", name="29").click()
page.get_by_role("textbox", name="Return").click() page.get_by_role("textbox", name="Return").click()
page.get_by_role("row", name="September 2023").get_by_role("cell").nth(1).click() page.get_by_role("row", name="September 2023").get_by_role("cell").nth(2).click()
page.get_by_role("cell", name="13", exact=True).click() page.get_by_role("cell", name="6", exact=True).click()
page.get_by_role("button", name="Search and book").click() page.get_by_role("button", name="Search and book").click()
page.get_by_label("Enter your vehicle registration").fill("KE69HRR") page.get_by_label("Enter your vehicle registration").fill("KE69HRR")
page.get_by_role("button", name="Find").click() page.get_by_role("button", name="Find").click()
@ -89,7 +90,9 @@ def run(playwright: Playwright) -> None:
page.locator("#slots div").filter(has_text="12:00To").locator("span").click() page.locator("#slots div").filter(has_text="12:00To").locator("span").click()
page.locator("div:nth-child(5) > .times > div:nth-child(2) > .radio-button").click() page.locator("div:nth-child(5) > .times > div:nth-child(2) > .radio-button").click()
page.locator(".ticket:visible").first.click() page.locator(
"div:nth-child(17) > .d-flex > div > .body > .radio-button"
).first.click()
page.get_by_role("button", name="Confirm and choose return ticket").click() page.get_by_role("button", name="Confirm and choose return ticket").click()
expect(page.get_by_text(return_label)).to_be_visible() expect(page.get_by_text(return_label)).to_be_visible()