File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ from playwright .sync_api import Playwright , sync_playwright
2+
3+
4+ def run (playwright : Playwright ) -> None :
5+ browser = playwright .chromium .launch (headless = False )
6+ context = browser .new_context ()
7+
8+ # Open new page
9+ page = context .new_page ()
10+
11+ # Go to https://www.jd.com/
12+ page .goto ("https://www.jd.com/" )
13+
14+ # Click text=女鞋
15+ with page .expect_popup () as popup_info :
16+ page .click ("text=女鞋" )
17+ page1 = popup_info .value
18+
19+ # Click div:nth-child(2) .lc-shop-logo-vertical__item-container div:nth-child(2) .lc-shop-logo-vertical__logo-cover .lc-shop-logo-vertical__logo
20+ with page1 .expect_popup () as popup_info :
21+ page1 .click ("div:nth-child(2) .lc-shop-logo-vertical__item-container div:nth-child(2) .lc-shop-logo-vertical__logo-cover .lc-shop-logo-vertical__logo" )
22+ page2 = popup_info .value
23+
24+ # Click :nth-match(:text("每满200减30"), 2)
25+ with page1 .expect_popup () as popup_info :
26+ page1 .click (":nth-match(:text(\" 每满200减30\" ), 2)" )
27+ page3 = popup_info .value
28+
29+ # Close page
30+ page2 .close ()
31+
32+ # Close page
33+ page3 .close ()
34+
35+ # Close page
36+ page1 .close ()
37+
38+ # Close page
39+ page .close ()
40+
41+ # ---------------------
42+ context .close ()
43+ browser .close ()
44+
45+
46+ with sync_playwright () as playwright :
47+ run (playwright )
You can’t perform that action at this time.
0 commit comments