diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..6c8e2a4 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,29 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Ensure browsers are installed + run: python -m playwright install --with-deps + - name: Run your tests + run: pytest --tracing=retain-on-failure + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-traces + path: test-results/ \ No newline at end of file diff --git a/__pycache__/test2_example.cpython-312-pytest-8.3.4.pyc b/__pycache__/test2_example.cpython-312-pytest-8.3.4.pyc new file mode 100644 index 0000000..93ce2e4 Binary files /dev/null and b/__pycache__/test2_example.cpython-312-pytest-8.3.4.pyc differ diff --git a/__pycache__/test_example.cpython-312-pytest-8.3.4.pyc b/__pycache__/test_example.cpython-312-pytest-8.3.4.pyc new file mode 100644 index 0000000..6a55453 Binary files /dev/null and b/__pycache__/test_example.cpython-312-pytest-8.3.4.pyc differ diff --git a/__pycache__/test_example0.cpython-312-pytest-8.3.4.pyc b/__pycache__/test_example0.cpython-312-pytest-8.3.4.pyc new file mode 100644 index 0000000..ec86097 Binary files /dev/null and b/__pycache__/test_example0.cpython-312-pytest-8.3.4.pyc differ diff --git a/__pycache__/test_example1.cpython-312-pytest-8.3.4.pyc b/__pycache__/test_example1.cpython-312-pytest-8.3.4.pyc new file mode 100644 index 0000000..9f961ec Binary files /dev/null and b/__pycache__/test_example1.cpython-312-pytest-8.3.4.pyc differ diff --git a/test-results/test-example0-py-test-get-started-link-chromium/trace.zip b/test-results/test-example0-py-test-get-started-link-chromium/trace.zip new file mode 100644 index 0000000..a7cc6d9 Binary files /dev/null and b/test-results/test-example0-py-test-get-started-link-chromium/trace.zip differ diff --git a/test-results/test-example0-py-test-has-title-chromium/trace.zip b/test-results/test-example0-py-test-has-title-chromium/trace.zip new file mode 100644 index 0000000..688dd6a Binary files /dev/null and b/test-results/test-example0-py-test-has-title-chromium/trace.zip differ diff --git a/test-results/test-example1-py-test-example-chromium/trace.zip b/test-results/test-example1-py-test-example-chromium/trace.zip new file mode 100644 index 0000000..ce06065 Binary files /dev/null and b/test-results/test-example1-py-test-example-chromium/trace.zip differ diff --git a/test_example0.py b/test_example0.py new file mode 100644 index 0000000..978e5d9 --- /dev/null +++ b/test_example0.py @@ -0,0 +1,29 @@ +import pytest +import re +from playwright.sync_api import Page, expect + +@pytest.fixture(scope="function", autouse=True) +def before_each_after_each(page: Page): + # Chromium, Firefox, or WebKit + # chromium.launch(headless=False, slow_mo=100) + + print("before the test runs") + + # Go to the starting url before each test. + page.goto("https://playwright.dev/") + yield + + print("after the test runs") + +def test_has_title(page: Page): + + # Expect a title "to contain" a substring. + expect(page).to_have_title(re.compile("Playwright")) + +def test_get_started_link(page: Page): + # page.wait_for_timeout(6000); + # Click the get started link. + page.get_by_role("link", name="Get started").click() + + # Expects page to have a heading with the name of Installation. + expect(page.get_by_role("heading", name="Installation")).to_be_visible() \ No newline at end of file diff --git a/test_example1.py b/test_example1.py new file mode 100644 index 0000000..0dadfa4 --- /dev/null +++ b/test_example1.py @@ -0,0 +1,21 @@ +import re +from playwright.sync_api import Page, expect + + +def test_example(page: Page) -> None: + page.goto("https://demo.playwright.dev/todomvc/#/") + page.get_by_placeholder("What needs to be done?").click() + page.get_by_placeholder("What needs to be done?").fill("Search for Googl") + page.get_by_placeholder("What needs to be done?").press("Enter") + page.get_by_label("Toggle Todo").check() + page.get_by_placeholder("What needs to be done?").click() + page.get_by_placeholder("What needs to be done?").fill("Learn python") + page.get_by_placeholder("What needs to be done?").press("Enter") + page.locator("li").filter(has_text="Learn python").get_by_label("Toggle Todo").check() + page.get_by_role("link", name="Active").click() + page.get_by_role("link", name="Completed").click() + page.get_by_role("button", name="Clear completed").click() + page.get_by_placeholder("What needs to be done?").click(button="right") + expect(page.get_by_placeholder("What needs to be done?")).to_be_visible() + expect(page.get_by_placeholder("What needs to be done?")).to_be_empty(); +