Skip to content

Commit 7678702

Browse files
committed
Update the Stealthy Playwright ReadMe
1 parent 1cc80c0 commit 7678702

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

examples/cdp_mode/playwright/ReadMe.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ pip install seleniumbase playwright
2424
## 💻 Usage
2525

2626
**Stealthy Playwright Mode** comes in three different formats:
27-
* `sb_cdp` "sync" format
28-
* `SB()` "nested sync" format
29-
* `cdp_driver` "async" format
27+
1. `sb_cdp` "sync" format
28+
2. `SB()` "nested sync" format
29+
3. `cdp_driver` "async" format
3030

3131
### 1. The lightweight "sync" format (`sb_cdp`)
3232

@@ -47,7 +47,7 @@ with sync_playwright() as p:
4747

4848
### 2. The full-suite "nested sync" format (`SB()`)
4949

50-
Best for hybrid projects where you need to switch between Selenium WebDriver and Playwright APIs in the same session. This is for power users!
50+
Best for hybrid projects where you need to switch between WebDriver and Playwright APIs in the same session.
5151

5252
```python
5353
from playwright.sync_api import sync_playwright
@@ -96,6 +96,36 @@ if __name__ == "__main__":
9696

9797
--------
9898

99+
### 🎭 Converting regular <b translate="no">Playwright</b> scripts to <b translate="no">Stealthy Playwright Mode</b>:
100+
101+
If you have a regular Playwright script that looks like this:
102+
103+
```python
104+
from playwright.sync_api import sync_playwright
105+
106+
with sync_playwright() as p:
107+
browser = p.chromium.launch(channel="chrome", headless=False)
108+
page = browser.new_context().new_page()
109+
page.goto("https://example.com")
110+
```
111+
112+
Then the Stealthy Playwright Mode version of that would look like this:
113+
114+
```python
115+
from playwright.sync_api import sync_playwright
116+
from seleniumbase import sb_cdp
117+
118+
sb = sb_cdp.Chrome()
119+
endpoint_url = sb.get_endpoint_url()
120+
121+
with sync_playwright() as p:
122+
browser = p.chromium.connect_over_cdp(endpoint_url)
123+
page = browser.contexts[0].pages[0]
124+
page.goto("https://example.com")
125+
```
126+
127+
--------
128+
99129
### 🎭 <b translate="no">Stealthy Playwright Mode</b> details:
100130

101131
The `sb_cdp` and `cdp_driver` formats don't use WebDriver at all, meaning that `chromedriver` isn't needed. From these two formats, Stealthy Playwright Mode can call [CDP Mode methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/cdp_mode_methods.md) and Playwright methods.
@@ -167,36 +197,6 @@ with sync_playwright() as p:
167197

168198
--------
169199

170-
### 🎭 Converting regular <b translate="no">Playwright</b> scripts to <b translate="no">Stealthy Playwright Mode</b>:
171-
172-
If you have a regular Playwright script that looks like this:
173-
174-
```python
175-
from playwright.sync_api import sync_playwright
176-
177-
with sync_playwright() as p:
178-
browser = p.chromium.launch(channel="chrome", headless=False)
179-
page = browser.new_context().new_page()
180-
page.goto("https://example.com")
181-
```
182-
183-
Then the Stealthy Playwright Mode version of that would look like this:
184-
185-
```python
186-
from playwright.sync_api import sync_playwright
187-
from seleniumbase import sb_cdp
188-
189-
sb = sb_cdp.Chrome()
190-
endpoint_url = sb.get_endpoint_url()
191-
192-
with sync_playwright() as p:
193-
browser = p.chromium.connect_over_cdp(endpoint_url)
194-
page = browser.contexts[0].pages[0]
195-
page.goto("https://example.com")
196-
```
197-
198-
--------
199-
200200
### 🎭 More details about <b translate="no">Stealthy Playwright Mode</b>:
201201

202202
Stealthy Playwright Mode uses the system's Chrome browser by default. There's also the option of setting `use_chromium=True` to use the unbranded Chromium browser instead, which still supports extensions. (With regular Playwright, you would generally need to run `playwright install` to download a special version of Chrome before running Playwright scripts, unless you set `channel="chrome"` to use the system's Chrome browser instead.)

0 commit comments

Comments
 (0)