Skip to content

Commit a7ab707

Browse files
committed
Update the Stealthy Playwright ReadMe
1 parent 1360eb4 commit a7ab707

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

examples/cdp_mode/playwright/ReadMe.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ The `SB()` format requires WebDriver, therefore `chromedriver` will be downloade
8888

8989
In the sync formats, `get_endpoint_url()` also applies `nest-asyncio` so that nested event loops are allowed. (Python doesn't allow nested event loops by default). Without this, you'd get the error: `"Cannot run the event loop while another loop is running"` when calling CDP Mode methods (such as `solve_captcha()`) from within the Playwright context manager. This `nest-asyncio` call is done behind-the-scenes so that users don't need to handle this on their own.
9090

91+
Default timeout values are different between Playwright and SeleniumBase. For instance, a 30-second default timeout in a Playwright method might be 10 seconds in the equivalent SeleniumBase method. When specifying custom timeout values, Playwright uses milliseconds, whereas SeleniumBase uses seconds. Eg. `page.wait_for_timeout(500)` is the equivalent of `sb.sleep(0.5)`.
92+
93+
Playwright's `:has-text()` selector is the equivalent of SeleniumBase's `:contains()` selector, except for one small difference: `:has-text()` isn't case-sensitive, but `:contains()` is.
94+
95+
Unlike normal Playwright, you don't need to run `playwright install` before running Stealthy Playwright Mode scripts because the system Chrome will be used. There's also the option of setting `use_chromium=True` to use the unbranded Chromium browser instead, which still supports extensions.
96+
9197
### 🎭 <b translate="no">Stealthy Playwright Mode</b> examples:
9298

9399
Here's an example that queries Microsoft Copilot:
@@ -105,16 +111,16 @@ with sync_playwright() as p:
105111
page = context.pages[0]
106112
page.goto("https://copilot.microsoft.com")
107113
page.wait_for_selector("textarea#userInput")
108-
sb.sleep(1)
114+
page.wait_for_timeout(1000)
109115
query = "Playwright Python connect_over_cdp() sync example"
110116
page.fill("textarea#userInput", query)
111117
page.click('button[data-testid="submit-button"]')
112-
sb.sleep(3)
118+
page.wait_for_timeout(4000)
113119
sb.solve_captcha()
114120
page.wait_for_selector('button[data-testid*="-thumbs-up"]')
115-
sb.sleep(4)
121+
page.wait_for_timeout(4000)
116122
page.click('button[data-testid*="scroll-to-bottom"]')
117-
sb.sleep(3)
123+
page.wait_for_timeout(3000)
118124
chat_results = '[data-testid="highlighted-chats"]'
119125
result = page.locator(chat_results).inner_text()
120126
print(result.replace("\n\n", " \n"))
@@ -134,9 +140,9 @@ with sync_playwright() as p:
134140
context = browser.contexts[0]
135141
page = context.pages[0]
136142
page.goto("https://www.bing.com/turing/captcha/challenge")
137-
sb.sleep(3)
143+
page.wait_for_timeout(2000)
138144
sb.solve_captcha()
139-
sb.sleep(3)
145+
page.wait_for_timeout(2000)
140146
```
141147

142148
--------

0 commit comments

Comments
 (0)