File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -162,3 +162,5 @@ cython_debug/
162
162
# Project
163
163
* .env
164
164
requirements.txt
165
+ generated
166
+ tests /test_codegen.py
Original file line number Diff line number Diff line change @@ -99,3 +99,28 @@ docs-serve: ## serve documentation
99
99
100
100
.PHONY : ci-test-docs
101
101
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
Original file line number Diff line number Diff line change
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 ))
You can’t perform that action at this time.
0 commit comments