Curious
Curious

Reputation: 282

No id, xpath, classnmae, teg, link, cssselector, name available in the html for selenium object identification java

I am trying to locate object in order to locate element on the web page but I am not able to find such object to use for element identification. I need to verify Column "Member Name" display on the web page.

Here is my HTML:

<tbody>
<tr class="gridheader">
<td width="143" nowrap="nowrap" style="border-right: 1px solid rgb(160, 160, 160); cursor: pointer;" onclick="javascript:__doPostBack('dgSearchResults$_ctl2$_ctl0','')" title="Click to Sort in Ascending order of Member Name ">

Upvotes: 0

Views: 30

Answers (1)

Marcello Grechi Lins
Marcello Grechi Lins

Reputation: 3410

If the structure of your table does not change, you can use indexes to fetch the first tag or something like that.

//tr[@class='gridheader']/td[1]

or

//tr[@class='gridheader']/td[position()=1]

Alternativelly, you can use something like checking whether a TD tag contains nowrap attribute, has width, or has a given text within a given tag.

//td[@class='gridheader']/td[contains(@width,'143') and contains(@nowrap,'nowrap')]

Upvotes: 2

Related Questions