How to identify an element via XPath when IDs keep changing

I am using a website, where the values of the elements are changing dynamically every time the elements load. The id's are dynamic and so is the XPath. I don't seem to have any unique identifier to locate the elements. Please advise on the best way to uniquely identify the element every time the page loads.

Here is the example of the XPath when the page loads for the first time:

.//*[@id='isc_HY']/table/tbody/tr/td

the same element when I do another run is as follows:

.//*[@id='isc_IP']/table/tbody/tr/td

There are several other elements on the page that looks like the above elements.

For example, there is an element with the following XPath that I don't need:

.//*[@id='isc_I2']/table/tbody/tr/td

Here is the HTML information for the same:

<div id="isc_HY" style="position: relative; display: inline-block; box-sizing: border-box; width: 100%; vertical-align: top; visibility: inherit; z-index: 204195; cursor: pointer;" eventproxy="isc_OBTabBarButtonChild_9"> <table width="68px" height="38px" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="OBTabBarButtonChildTitleOver" valign="center" nowrap="true" align="right" onfocus="isc_OBTabBarButtonChild_9_label.$47()" tabindex="-1">Item Pricing</td> </tr> </tbody> </table> </div> </div> <div id="isc_I0" class="OBTabBarButtonChildTopOver" onscroll="return isc_OBTabBarButtonChild_9.$lh()" style="position: absolute; left: 208px; top: 0px; width: 96px; height: 38px; z-index: 204194; box-sizing: border-box; overflow: hidden; cursor: pointer; outline-style: none;" tabindex="4914" onblur="if(window.isc)isc.EH.blurFocusCanvas(isc_OBTabBarButtonChild_9,true);" onfocus="if(event.target!=this)return;isc.EH.focusInCanvas(isc_OBTabBarButtonChild_9,true);" role="tab" eventproxy="isc_OBTabBarButtonChild_9"> <div id="isc_I1" onscroll="return isc_OBTabBarButtonChild_10.$lh()" style="position: absolute; left: 319px; top: 0px; width: 59px; height: 38px; z-index: 204213; box-sizing: border-box; overflow: hidden; cursor: pointer; outline-style: none;" tabindex="-1" onblur="if(window.isc)isc.EH.blurFocusCanvas(isc_OBTabBarButtonChild_10_label,true);" onfocus="if(event.target!=this)return;isc.EH.focusInCanvas(isc_OBTabBarButtonChild_10_label,true);" role="label" eventproxy="isc_OBTabBarButtonChild_10">

I am looking to click on the "Item Pricing" text.

--------------Solutions-------------

You can select a table cell whose contents equals a string such as "Item Pricing" via the following XPath:

//td[. = 'Item Pricing']

Category:html Time:2018-11-07 Views:0

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.337 (s). 13 q(s)