diff --git a/pages/contact_page.py b/pages/contact_page.py new file mode 100644 index 0000000..5c6154c --- /dev/null +++ b/pages/contact_page.py @@ -0,0 +1,15 @@ +from playwright.sync_api import Page + +class ContactPage: + def __init__(self, page: Page) -> None: + self.page = page + self.email = page.get_by_test_id("contact-email") + self.phone = page.get_by_test_id("contact-phone") + self.address = page.get_by_test_id("contact-address") + self.hours = page.get_by_test_id("office-hours-row") + + def goto(self) -> None: + self.page.goto("/contact") + + + \ No newline at end of file diff --git a/tests/features/contact.feature b/tests/features/contact.feature new file mode 100644 index 0000000..2c0b539 --- /dev/null +++ b/tests/features/contact.feature @@ -0,0 +1,6 @@ +Feature: Contacts + + Scenario: Watching Email + When I am on Contact page. + Then I should see the Email "student.office@example.com". + \ No newline at end of file diff --git a/tests/test_contact.py b/tests/test_contact.py new file mode 100644 index 0000000..987dfcc --- /dev/null +++ b/tests/test_contact.py @@ -0,0 +1,16 @@ +from playwright.sync_api import Page, expect +from pytest_bdd import given, parsers, scenarios, then, when + +from pages.contact_page import ContactPage + +scenarios("features/contact.feature") + +@when("I am on Contact page.", target_fixture="contact_page") +def open_contact_page(page: Page) -> ContactPage: + contact_page = ContactPage(page) + contact_page.goto() + return contact_page + +@then(parsers.parse('I should see the Email "{email}".')) +def see_email(contact_page: ContactPage, email: str) -> None: + expect(contact_page.email).to_have_text(email) \ No newline at end of file