Skip to content

Select second element that have same selector #3238

@SandPipper

Description

@SandPipper

Hi, I can't figure out how I could use/select/click second element if it have same selector as first one ,per example:

<div> 
*shadow dom* 
<button>No</button>
<button>Yes</button>
</div>

if I use just click it's always pick up first element:

with SB(uc=True, test=True, incognito=True, locale_code="en") as sb:
    sb.click("div::shadow button")

if I use find_elements it's not work with ::shadow selector

with SB(uc=True, test=True, incognito=True, locale_code="en") as sb:
    sb.find_elements("div::shadow button") # {"status":32,"value":"An invalid or illegal selector was specified"}

I also tried to select by text but it's also don't work, probably because there also shadow dom in buttons along with text

with SB(uc=True, test=True, incognito=True, locale_code="en") as sb:
    sb.find_elements("div::shadow button[text(), "Yes"]") # don't find element, not sure if syntax right here, I take it from selenium

Can't find something that could help in docs, please help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    UC Mode / CDP ModeUndetected Chromedriver Mode / CDP ModequestionSomeone is looking for answers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions