Skip to content

Commit 43d5c0e

Browse files
committed
add task runner commands
1 parent 589bf24 commit 43d5c0e

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,5 @@ cython_debug/
162162
# Project
163163
*.env
164164
requirements.txt
165+
generated
166+
tests/test_codegen.py

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,28 @@ docs-serve: ## serve documentation
9999

100100
.PHONY: ci-test-docs
101101
ci-test-docs: docs ## run CI test for documentation
102+
103+
# ---
104+
# Project
105+
# ---
106+
107+
.PHONY: test-verbose
108+
test-verbose: ## run tests with verbose
109+
uv run pytest \
110+
--capture=no \
111+
--verbose \
112+
--headed \
113+
--tracing on \
114+
--video on \
115+
--screenshot on \
116+
--output generated
117+
118+
TRACE_ZIP ?= generated/tests-test-core-py-test-get-started-link-chromium/trace.zip
119+
.PHONY: show-trace
120+
show-trace: ## show trace
121+
uv run playwright show-trace $(TRACE_ZIP)
122+
123+
.PHONY: codegen
124+
codegen: ## generate test code
125+
uv run playwright codegen \
126+
--output tests/test_codegen.py

docs/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,24 @@ make install-deps-dev
1414
```
1515

1616
- [[BUG] Host system is missing dependencies to run browsers (WSL2) #19100](https://github.com/microsoft/playwright/issues/19100)
17+
18+
## Guides
19+
20+
To run some demos, please follow the instructions below.
21+
22+
```bash
23+
# Run tests in verbose mode
24+
make test-verbose
25+
26+
# Show traces
27+
make show-trace
28+
29+
# Generate code
30+
make codegen
31+
```
32+
33+
## [Microsoft Playwright Testing](https://learn.microsoft.com/ja-jp/azure/playwright-testing/)
34+
35+
- [Get Started Sample](https://github.com/microsoft/playwright-testing-service/tree/main/samples/get-started)
36+
37+
## [Playwright MCP server](https://github.com/microsoft/playwright-mcp)

tests/test_hatena_bookmark.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
3+
from playwright.sync_api import Page
4+
5+
6+
def test_hatena_bookmark(page: Page):
7+
page.goto("https://b.hatena.ne.jp/hotentry/all")
8+
9+
entries = []
10+
for entry in page.query_selector_all(".entrylist-contents-main"):
11+
title_element = entry.query_selector(".entrylist-contents-title a")
12+
bookmark_element = entry.query_selector(".entrylist-contents-users span")
13+
14+
if title_element and bookmark_element:
15+
title = title_element.inner_text()
16+
url = title_element.get_attribute("href")
17+
bookmarks = bookmark_element.inner_text().replace("users", "").strip()
18+
19+
entries.append({"title": title, "url": url, "bookmarks": int(bookmarks) if bookmarks.isdigit() else 0})
20+
21+
print(json.dumps(entries, indent=2, ensure_ascii=False))

0 commit comments

Comments
 (0)