How i can evaluate an ASYNC script in cdp mode? #3553
|
In the normal mode, I have the But when using CDP I only have the How I can await a Promise from a script using cdp mode? |
Replies: 3 comments
|
See the SeleniumBase/examples/cdp_mode/raw_async.py Lines 8 to 12 in 8317bc8 You have to stay in the same tab for CDP Mode. |
|
For anyone coming here for evaluating async JS in sync pure CDP mode, this is what I found to work: answer = sb.loop.run_until_complete(
sb.page.evaluate(
expression="""Promise.resolve(42)""",
await_promise=True))The standard |

See the
asyncexample for utilizingawait: SeleniumBase/examples/cdp_mode/raw_async.py:SeleniumBase/examples/cdp_mode/raw_async.py
Lines 8 to 12 in 8317bc8
You have to stay in the same tab for CDP Mode.
If you want to switch between tabs, you have to reconnect the driver with
sb.connect()first.Here are a few examples that mix CDP Mode with WebDriver to do that:
SeleniumBase/examples/cdp_mode/raw_easyjet.py
Line 29 in 8317bc8
SeleniumBase…