How to find Xpath for a dynamic element in selenium webdriver

I couldn’t be able to find an unique Xpath.

I already tried this xpaths but doesn’t works:

xpath=(//span[text(), ‘Show Details’])[76]

In this case the ‘Show details’ comes when we add new employee, so every-time new show details link text generates.

How to find Xpath for a dynamic element in selenium webdriver

HTML of Employee 5454545 that has a Show details link text:

<span class="infor-social-showDetails message-action-menu">
<span class="message-action-menu-text infor-social-showDetailsText" data-inforprops="{"eventName":"GetDetails","UploadIdentifier":"","MsgId":"76","FeedSource":"4","MsgDate":"1433484223883","IONObjectType":"ION_ALERT"}">                     Show Details                 </span>

luckperez Supporter Asked on July 1, 2015 in Selenium WebDriver.
Add Comment
1 Answer(s)

I’ve had such problem)
You can find xpath=(//span[contains(text(), ‘Show Details’]))—- use contains because text has spaces. WebDriver will find your first link.
To find second link you should use some think like following-sibling

If you give me url or more html code, I’ll give you exect xpath(piece of html that you give is very inconvenient)

victor Reviewer Answered on July 1, 2015.

Hi victor,Thank you so much for the response. Unfortunately i cannot send you the URL because it is only in our company network, I’m trying to post the whole html of the page but it wont display here. I can email to you the html code if you have some time. or you could look into this link, It has more info about the problem.  Thanks and God bless 

on July 2, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.