0

I'm using the selenium IDE for Chrome on Mac Big Sur. I notice the IDs for a particular page keep changing and so I want my SElenium playback to use something more constant. Specifically, I'd like to capture a click on this element ...

<th scope="col" role="columnheader" data-field="parentName" aria-haspopup="true" rowspan="1" data-title="Parent Institution" data-index="1" id="05abd234-04a8-409c-99e9-90fd772f0dd2" class="k-header k-with-icon k-filterable" data-role="columnsorter"><a class="k-grid-filter" href="#" title="Filter" aria-label="Filter" tabindex="-1"><span class="k-icon k-i-filter"></span></a><a class="k-link" href="#">Parent Institution</a></th>

So I thought I could use the TH title attribute. In my ".side" file, I set up my selector like so

}, {
  "id": "b3839cf6-9347-4a43-9208-922e2975fc33",
  "comment": "click parent menu",
  "command": "click",
  "target": "css=title^='Parent Institution'",
  "targets": [
    ["css=#5ba47ffd-b9ec-41e6-b4e6-924bf3d688bc", "css:finder"],
    ["xpath=//th[@id='dd03982f-9fdb-4140-bb24-93f9582c6bad']/a/span", "xpath:idRelative"],
    ["xpath=//th[3]/a/span", "xpath:position"]
  ],
  "value": ""
}, {

But when doing playback, the IDE still seems to fail to detect this element. Is there a different way I should be writing this command to accurately select CSS based on the TH "title" attribute?

Dave
  • 15,639
  • 133
  • 442
  • 830

1 Answers1

0

The value of the id attribute of the <th> element is dynamically generated. So everytime you access the application or within a interval the value of the id attribute of the <th> element will get changed.

Moreover, the clickable element is a tag:

<a class="k-link" href="#">Parent Institution</a>

Solution

To click on the element you can use either of the following Locator Strategies:

  • Using link_text:

    Parent Institution
    
  • Using css_selector:

    th[data-field='parentName'][data-title='Parent Institution'] a.k-grid-filter[title='Filter'][aria-label='Filter'] +a.k-link
    
  • Using xpath:

    //th[@data-field='parentName'][@data-title='Parent Institution']//a[text()='Parent Institution']
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352