Unable to locate a precise webelement to be clickable in a list given by Selenium CSS Selector

24 Views Asked by At

I am looking for a way to click on a precise button webelement located on a table.

Using selenium selector I could identify about 12 elements having the same class name but printing text or attribute does not differentiate them.

l = browser.find_elements(By.CSS_SELECTOR,'[class="ajaxOpen user"]')

This gives me a dozen of web elements but I want to select only one to click. Unfortunately, the location may vary depending on the number of proposed event. XPATH method would not give reliable position.

The webpage presents a serie of events, from which I want to extract the list of participant Here is the part HTML of one table :

<li class="ajaxOpen user" data-url="_Programme_lstparticipants&amp;id=3665" title="Liste des participants" data-titre="Liste des participants"></li>

Each event has a unique id number and it looks like data-url variable is passed to the AjaxOpen class (here with id = 3665 which is unique)

I tried several methods from selenium without success, xpath for example here is the relative Xpath //div[3]//ul[1]//li[5]//ul[1]//li[1] The Div tag changes depending on number of div tables on the page. so when the website proposes a new event, the actual button may migrate to div[4]

I am not able to locate this particular element within the list given by CSS SELECTOR.

Ideally, is there a way to create a custom Locator without iterating the List just by locating the data-url variable which is not shown on the page?

Thank you in advance

0

There are 0 best solutions below