Search This Blog

Sunday, July 6, 2014

How to find a sibling of a node

How to find a sibling of a node
There are many situation when we get difficulties to find the elements which do not have identification/attribute but their immediate siblings has some identification.

In above example if we want to get the text of H1 we can not use //h1 because there are more than one h1 on the page. If you see a and h1 both are siblings and children of div//[@class='title pad_btm15']
By using a sibling element's property we can find out his sibling. In above example we know id of a which is "mainContent" then we can get its sibling



If you have more siblings with no attribute or no unique attribute like below.

then we can use the position us find out exact element using xpath:
Samsung Android Mobile

Nokia Android Mobile :


  1. This comment has been removed by a blog administrator.

  2. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.

  3. I got better idea in finding the sibling of a node. Please explain me the method to connect the node machine to hub machine in selenium for cross browser testing.
    Selenium Training in Chennai

  4. It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

  5. Advanced Selenium Framework Training in Chennai by Vishwa

    Hi, Reach Mr.Vishwa for Best Selenium and Coded UI Training in Chennai with real time project assistance. This people will teach everything from the basics up to advanced level scenarios from frameworks.

    I learned from Mr.Vishwa and Raj they are very good automation people for Selenium Frameworks. After joined with them I learned many things and now I am writing automation scripts in own project. Vishwa 9003085882
    selenium training in chennai

  6. It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

  7. This one is much helpful, Very clear explanation about the topic.

    Latest Update here:

  8. Selenium Testing Real Time Hands on Training in Chennai…

    Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

    If You need a Best Trainer in Selenium Testing??? Then be ready for a DEMO From the Trainer MR.Karthick

    Both Classroom/Online Training is Available!!!!!!

  9. We can learn everyday something new in software testing. Automation is a topic that covers most of the part of testing and learning testing. Thanks for sharing this valuable information with a complete explanation.

  10. thanks for this beautiful post of blog I really liked your blog, It is very goof for freshers
    Selenium training and Institute
    Selenium Training in Marathalli
    Selenium Course in Bangalore