0

I have the following element (stripped for brevitiy):

<div id="searchButton">
    <div>
        <div>
            "Search"
            ::after
        </div>
    </div>
</div>

Which renders to this element:

enter image description here

I now want to click the dropdown arrow.

How to write a selector for this?

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37

1 Answers1

0

Depending on Your CSS You can try this:

const element = await page.locator('div:has-text("Search")')
const arrow = await element.evaluate((e1) => {     
       return window.getComputedStyle(e1,':after').top
    })

This should return position and then use mouse click on coordinates, but its possible that this will return auto and in that case try to find property that You could use instead of .top

senaid
  • 534
  • 2
  • 8