Compare commits

..

10 commits

2 changed files with 21 additions and 21 deletions

3
.gitignore vendored Normal file
View file

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

View file

@ -1,7 +1,8 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
from datetime import datetime, date import re
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
@ -54,29 +55,27 @@ 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 = page.locator("div.ui-datepicker-month").first month_and_year = month_row.inner_text().strip()
print(month) if month_and_year == "August 2023":
print(month.text_content()) month_row.get_by_role("cell").nth(1).click()
else:
page.close() assert month_and_year == "September 2023"
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(2).click() page.get_by_role("row", name="September 2023").get_by_role("cell").nth(1).click()
page.get_by_role("cell", name="6", exact=True).click() page.get_by_role("cell", name="13", 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()
@ -90,9 +89,7 @@ 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( page.locator(".ticket:visible").first.click()
"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()