using python selenium4 with locators with the same class name

49 Views Asked by At

I'm trying to locate a filter type button on a page, but there are many with the same nameclass, they differ only by one more argument (number of column), I don't know how to use it

<div class="e-filtermenudiv e-icons e-icon-filter" _ngcontent-llr-c3="" e-mappinguid="e-flmenu-grid-column1"></div>
<div class="e-filtermenudiv e-icons e-icon-filter" _ngcontent-llr-c3="" e-mappinguid="e-flmenu-grid-column5"></div>
<div class="e-filtermenudiv e-icons e-icon-filter" _ngcontent-hbl-c3="" e-mappinguid="e-flmenu-grid-column4"></div>
<div class="e-filtermenudiv e-icons e-icon-filter" _ngcontent-hbl-c3="" e-mappinguid="e-flmenu-grid-column8"></div>

I want the instruction in selenium 4 of python

lem = driver.find_element("xpath","//div[@class='e-filtermenudiv e-icons e-icon-filter e-filtered'][@e-mappinguid='e-flmenu-grid-column9']").click()

1

There are 1 best solutions below

0
On

Try "//div[@class='e-filtermenudiv e-icons e-icon-filter' and @e-mappinguid='e-flmenu-grid-column1']" Change column number. Here is a website where you can evaluate your Xpath selector.