Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-parmar committed Dec 10, 2024
1 parent 29c7e07 commit 814ff29
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -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/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions test_example0.py
Original file line number Diff line number Diff line change
@@ -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()
21 changes: 21 additions & 0 deletions test_example1.py
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 814ff29

Please sign in to comment.