CDP mode with shadowroot interaction #3552
nikita-devbox
started this conversation in
General
Replies: 1 comment 1 reply
-
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.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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