Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pages/contact_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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")

def goto(self) -> None:
self.page.goto("/contact")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manca il newline a fine file, vale anche per gli altri tre file della PR

7 changes: 7 additions & 0 deletions tests/features/contact_email.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Contact

Background:
Given I am on the contact page

Scenario: Correct Email
Then I see the contact email "student.office@example.com"
14 changes: 14 additions & 0 deletions tests/test_contact_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import re

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re non lo usi, puoi toglierlo


from playwright.sync_api import Page, expect

from pages.contact_page import ContactPage


def test_contact_email(page: Page) -> None:
# arrange
contact_page = ContactPage(page)
contact_page.goto()

# assert
expect(contact_page.email).to_have_text("student.office@example.com")
18 changes: 18 additions & 0 deletions tests/test_contact_email_bdd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from playwright.sync_api import Page, expect
from pytest_bdd import scenarios, given, when, then, parsers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when non lo usi, puoi toglierlo


from pages.contact_page import ContactPage

scenarios("features/contact_email.feature")


@given("I am on the 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 see the contact email "{email}"'))
def see_contact_email(contact_page: ContactPage, email: str) -> None:
expect(contact_page.email).to_have_text(email)
Loading