You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: help_docs/syntax_formats.md
+10-19
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@
33
33
<li><ahref="#sb_sf_22"><strong>22. The driver manager (via context manager)</strong></a></li>
34
34
<li><ahref="#sb_sf_23"><strong>23. The driver manager (via direct import)</strong></a></li>
35
35
<li><ahref="#sb_sf_24"><strong>24. CDP driver (async/await API. No Selenium)</strong></a></li>
36
-
<li><ahref="#sb_sf_25"><strong>25. CDP driver (SB-CDP sync API. No Selenium)</strong></a></li>
36
+
<li><ahref="#sb_sf_25"><strong>25. CDP driver (SBCDP Sync API. No Selenium)</strong></a></li>
37
37
</ul>
38
38
</blockquote>
39
39
@@ -1019,14 +1019,13 @@ This format provides a pure CDP way of using SeleniumBase (without Selenium or a
1019
1019
```python
1020
1020
import asyncio
1021
1021
import time
1022
-
from seleniumbase.undetectedimport cdp_driver
1022
+
from seleniumbase import cdp_driver
1023
1023
1024
1024
1025
1025
asyncdefmain():
1026
-
driver =await cdp_driver.cdp_util.start_async()
1027
-
page =await driver.get("about:blank")
1028
-
await page.set_locale("en")
1029
-
await page.get("https://www.priceline.com/")
1026
+
url ="https://www.priceline.com/"
1027
+
driver =await cdp_driver.start_async(lang="en")
1028
+
page =await driver.get(url)
1030
1029
time.sleep(3)
1031
1030
print(await page.evaluate("document.title"))
1032
1031
element =await page.select('[data-testid*="endLocation"]')
@@ -1043,25 +1042,17 @@ if __name__ == "__main__":
1043
1042
(See <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_async.py">examples/cdp_mode/raw_async.py</a> for the test.)
1044
1043
1045
1044
<aid="sb_sf_25"></a>
1046
-
<h2><imgsrc="https://seleniumbase.github.io/img/logo3b.png"title="SeleniumBase"width="32" /> 25. CDP driver (SB-CDP sync API. No Selenium)</h2>
1045
+
<h2><imgsrc="https://seleniumbase.github.io/img/logo3b.png"title="SeleniumBase"width="32" /> 25. CDP driver (SBCDP Sync API. No Selenium)</h2>
1047
1046
1048
-
This format provides a pure CDP way of using SeleniumBase (without Selenium or a test runner). The expanded SB-CDP sync API is used. Here's an example:
1047
+
This format provides a pure CDP way of using SeleniumBase (without Selenium or a test runner). The expanded SBCDP Sync API is used. Here's an example:
1049
1048
1050
1049
```python
1051
-
import asyncio
1052
-
from seleniumbase.core import sb_cdp
1053
-
from seleniumbase.undetected import cdp_driver
1050
+
from seleniumbase import sb_cdp
1054
1051
1055
1052
1056
1053
defmain():
1057
-
url0 ="about:blank"# Set Locale code from here first
1058
-
url1 ="https://www.priceline.com/"# (The "real" URL)
1059
-
loop = asyncio.new_event_loop()
1060
-
driver = cdp_driver.cdp_util.start_sync()
1061
-
page = loop.run_until_complete(driver.get(url0))
1062
-
sb = sb_cdp.CDPMethods(loop, page, driver)
1063
-
sb.set_locale("en") # This test expects English locale
1064
-
sb.open(url1)
1054
+
url ="https://www.priceline.com/"
1055
+
sb = sb_cdp.Chrome(url, lang="en")
1065
1056
sb.sleep(2.5)
1066
1057
sb.internalize_links() # Don't open links in a new tab
Users should first [Enable Rosetta in Docker Desktop](https://stackoverflow.com/a/76586216/7058266). (Otherwise Chrome will crash on launch with errors such as: `"InvalidSessionIdException"` and `"Unable to receive message from renderer"`)
**M1/M2 Mac users** should also see [StackOverflow.com/a/76586216/7058266](https://stackoverflow.com/a/76586216/7058266) to **Enable Rosetta in Docker Desktop**. (Otherwise **you will** encounter errors like this when Chrome tries to launch: `"Chrome failed to start: crashed."`)
#### 4. Run [the example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) with Chrome inside your Docker: (Once the test completes after a few seconds, you'll automatically exit the Docker shell)
0 commit comments