Skip to content

Commit 589bf24

Browse files
committed
add an example test
1 parent ddc7a85 commit 589bf24

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ info: ## show information
1616
install-deps-dev: ## install dependencies for development
1717
uv sync --all-extras
1818
uv run pre-commit install
19+
uv run playwright install
1920

2021
.PHONY: install-deps
2122
install-deps: ## install dependencies for production

docs/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
11
# workshop-playwright-python
2+
3+
## Installation
4+
5+
To set up the environment, details are provided in [Playwright for Python > Installation](https://playwright.dev/python/docs/intro).
6+
In this workshop, we provide a script to install the necessary dependencies.
7+
8+
```bash
9+
git clone https://github.com/ks6088ts-labs/workshop-playwright-python.git
10+
cd workshop-playwright-python
11+
12+
# Install the dependencies
13+
make install-deps-dev
14+
```
15+
16+
- [[BUG] Host system is missing dependencies to run browsers (WSL2) #19100](https://github.com/microsoft/playwright/issues/19100)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = "A GitHub template repository for Python"
55
readme = "README.md"
66
requires-python = ">=3.10"
77
dependencies = [
8+
"playwright>=1.52.0",
89
"pytest-playwright>=0.7.0",
910
]
1011

tests/test_core.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import logging
2+
import re
3+
4+
from playwright.sync_api import Page, expect
25

36
from workshop_playwright_python.core import hello_world
47

@@ -13,3 +16,20 @@ def test_hello_world_non_verbose(caplog):
1316
with caplog.at_level(logging.DEBUG):
1417
hello_world(verbose=False)
1518
assert "Hello, world!" not in caplog.text
19+
20+
21+
def test_has_title(page: Page):
22+
page.goto("https://playwright.dev/")
23+
24+
# Expect a title "to contain" a substring.
25+
expect(page).to_have_title(re.compile("Playwright"))
26+
27+
28+
def test_get_started_link(page: Page):
29+
page.goto("https://playwright.dev/")
30+
31+
# Click the get started link.
32+
page.get_by_role("link", name="Get started").click()
33+
34+
# Expects page to have a heading with the name of Installation.
35+
expect(page.get_by_role("heading", name="Installation")).to_be_visible()

uv.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)