XPATH and text of the elements are constantly updating, what is the best way to identify an element

Here is the XPath for element x the first time a page loads:

.//*[@id='001g000000YJnpR_00Nb0000004Lzej_body']/table/tbody/tr[3]/td[3]

text on this page is: "text1".

Here is the XPath for same element x the second time it loads:

//*[@id="001g000000YJnm8_00Nb0000004Lzej_body"]/table/tbody/tr[3]/td[3]

text on this page is: "text2".

Element doesn't have a name or id and here is the HTML code: '<'td class="dataCell">vxgkVwD7JvnOBKaGCIS7'<'/td'>'

Please assist.

Upvotes: 1

Views: 196

Answers (1)

alecxe
alecxe

Reputation: 473873

What about checking for the id attribute to contain body string using contains():

//*[contains(@id, "body")]/table/tbody/tr[3]/td[3]

Though, posting the complete HTML code of the table could help to provide you with a more reliable and readable XPath expression.

Upvotes: 5

Related Questions