This is a migrated thread and some comments may be shown as answers.

Need help with locating dynamic elements by Xpath

3 Answers 257 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Surya
Top achievements
Rank 1
Surya asked on 28 Oct 2014, 11:52 AM
Hi,

I have 2 sites of similar page structure. Here i need to navigate to another page from home by clicking on "first" link (menu option) from left-pane. I am not sure of the name of the link or it's href value. But i have to click on the first link from left-navigation-pane. The link in first site might be completely different from second site. Can i locate this element by using it's 'UL' index in the left pane ?

For the 1st site's element XPath was - /html[1]/body[1]/form[1]/div[2]/div[1]/ul[1]/li[2]/a[1]
For the 2nd site's element XPath was - /html[1]/body[1]/form[1]/div[3]/div[4]/div[1]/div[2]/div[1]/ul[1]/li[2]/a[1]
So i have tried element finding logic as 'XPath' - 'StartsWith' - /html[1]/body[1]/form[1] & 'XPath' - 'EndsWith' - /div[1]/ul[1]/li[2]/a[1]
But the telerik is unable to locate the element as there are other links at the  bottom of the page matching with the same above logic.


Could somebody please help me with this ? I should be able to run the same script/steps in 2 sites.
Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 31 Oct 2014, 08:20 AM
Hi Surya,

Thank you for contacting us.

Unfortunately without seeing the DOM tree we can shoot into the dark only.

Please send us a screen shot with the DOM of both sites where this link is so we can help you with the find expression.

Looking forward to hearing from you.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Surya
Top achievements
Rank 1
answered on 31 Oct 2014, 09:53 AM
Hi Boyan,

Thanks for the response.

I've attached 2 screenshots showing DOM structure of 2 sites. And the desired element is shown as 'Selected' in Orange. Please let me know if you need more details.
0
Boyan Boev
Telerik team
answered on 05 Nov 2014, 08:45 AM
Hello Surya,

You can create a generic find expression to locate the second list item in the first unordered list in the site.

Please see the attached screen shot.

Let me know if this helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Surya
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Surya
Top achievements
Rank 1
Share this question
or