Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research: Playwright #2442

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ USER $USER
# install devcontainer requirements
RUN pip install -e .[dev,test]

USER root
RUN pip install pytest-playwright playwright -U
RUN playwright install-deps

USER $USER
RUN playwright install

# docs requirements are in a separate file for the GitHub Action
COPY docs/requirements.txt docs/requirements.txt
RUN pip install -r docs/requirements.txt
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ dev = [
test = [
"coverage",
"pytest",
"playwright",
"pytest-django",
"pytest-mock",
"pytest-playwright",
"pytest-socket",
]

Expand Down
21 changes: 21 additions & 0 deletions run_playwright.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Basic command (runs Chromium)

pytest -k test_example --headed --slowmo 1000

# (From here, run second test only in the interest of time)

# Use --browser to run with a different browser

# pytest -k test_get_started_link --headed --browser firefox

# Use --device to run with different viewports

# pytest -k test_get_started_link --headed --device "iPhone 13"

# Run in debug mode (https://playwright.dev/python/docs/running-tests#debugging-tests)

# PWDEBUG=1 pytest -s -k test_get_started_link

# More CLI options:
# https://playwright.dev/python/docs/test-runners
# https://playwright.dev/python/docs/running-tests#command-line
29 changes: 29 additions & 0 deletions test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import re
from playwright.sync_api import Page, expect


def test_has_title(page: Page):
page.goto("https://dev-benefits.calitp.org/")

# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Cal-ITP"))


def test_get_started_link(page: Page):
page.goto("https://dev-benefits.calitp.org/")

# Click the Choose your provider link.
page.get_by_text("Choose your provider").click()

page.get_by_text("California State Transit (dev)").click()

page.get_by_label("Medicare Cardholder").click()

page.get_by_text("Choose this benefit").click()

page.get_by_text("Continue to Medicare.gov").click()

page.wait_for_timeout(5000)

# # Expects page to have a heading with the name of Installation.
# expect(page.get("heading", name="Installation")).to_be_visible()
7 changes: 3 additions & 4 deletions tests/cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
module.exports = {
downloadsFolder: "downloads",
fixturesFolder: "fixtures",
screenshotsFolder: "screenshots",
Expand All @@ -15,5 +13,6 @@ module.exports = defineConfig({
},
specPattern: "specs/**/*.cy.{js,jsx,ts,tsx}",
supportFile: false,
baseUrl: "http://localhost:11369",
},
});
};
Loading