-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
How i can evaluate an ASYNC script in cdp mode? #3553
-
In the normal mode, I have the self.execute_async_script(script, timeout=None)
But when using CDP I only have the sb.cdp.evaluate(expression)
How I can await a Promise from a script using cdp mode?
Beta Was this translation helpful? Give feedback.
All reactions
See the async
example for utilizing await
: 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:
-
sb.connect()
Replies: 2 comments
-
image
And one more question, I was trying to reutilize the same browser and open new tabs, but after activating cdp mode, it will not open a new tab.
Is this intended?
Beta Was this translation helpful? Give feedback.
All reactions
-
See the async
example for utilizing await
: 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:
- sb.connect()
- sb.connect()
Beta Was this translation helpful? Give feedback.