Need help with locating dynamic elements by Xpath

4 posts, 0 answers
  1. Surya
    Surya avatar
    3 posts
    Member since:
    Oct 2014

    Posted 28 Oct 2014 Link to this post

    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

  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 31 Oct 2014 Link to this post

    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!
  3. Surya
    Surya avatar
    3 posts
    Member since:
    Oct 2014

    Posted 31 Oct 2014 in reply to Boyan Boev Link to this post

    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.
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 05 Nov 2014 Link to this post

    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!
Back to Top