CDP mode with shadowroot interaction #3552
Replies: 3 comments 5 replies
-
As in the example below, you have to use from seleniumbase import SB
with SB(uc=True) as sb:
url = "https://seleniumbase.io/other/shadow_dom"
sb.activate_cdp_mode(url)
element = sb.cdp.get_nested_element("fancy-tabs", "section")
print(element.text) Once you have an element, you can use the CDP Element API to do more, such as Related methods: SeleniumBase/examples/cdp_mode/ReadMe.md Lines 401 to 402 in 8317bc8 |
Beta Was this translation helpful? Give feedback.
-
I tried the solution using the following code:
But i still get an error - the element in the shadow root is not found:
|
Beta Was this translation helpful? Give feedback.
-
Hello - it seems get_nested_element is still not working - find attached this example -
I get this error:
Is the function "get_nested_element" still not working or am i doing something wrong? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings,
I am happy to have discovered this well-maintained project and have been studying the docs now for a week and been conducting small tests.
During the past few days however, I've struggled with detecting / interacting with elements under one, or multiple open shadow root elements, which according to the example test files of seleniumbase repository should work, so I am forced to ask, if anyone could point out what am I doing wrong.
My issue as follows:
self.selbase.cdp.find_elements(selector) // where selector = "onboarding-modal::shadow #w-button"`
self.selbase.cdp.gui_click_element(parent_selector)
try1: Element {onboarding-modal w-button[variant="secondary"]} was not found after 7 seconds!
try2: Element {#modal-div w-button[variant="secondary"]} was not found after 7 seconds!
My questions are:
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions