Pages

Search This Blog

Sunday, July 6, 2014

How to use preceding-sibling and following-sibling in xpath to find sibling nodes

How to use preceding-sibling and following-sibling in xpath to find sibling nodes


How to get all the preceding siblings of Apple

Xpath: "//ul/li[contains(text(),'Apple Mobiles')]/preceding-sibling::li"

This will give "Samsung Mobiles"

How to get all the following  siblings of Apple
Xpath: "//ul/li[contains(text(),'Apple Mobiles')]/following-sibling::li"

This will give all the preceding siblings ( Nokia Mobiles, HTC Mobiles, Sony Mobiles, Micromax mobiles)

There is trick to use preceding-sibling and following-sibling. Place matters when you use this at beginning it will give you reverse result
When you use preceding-sibling at beginning then it will give result  ( Nokia Mobiles, HTC Mobiles, Sony Mobiles, Micromax mobiles) instead of Samsung mobiles.

Xpath : "//li[preceding-sibling::li='Apple Mobiles']"

This will give Samsung mobiles.
when you use following-sibling at the beginning then it will give reverse result. Instead of giving all below nodes of Apple mobile this will give Samsung Mobiles.
Xpath: "//li[following-sibling::li='Apple Mobiles']"
Now the question is how to get all the nodes between Apple Mobiles and Sony Mobiles.

Xpath : "//ul/li[preceding-sibling::li='Apple Mobiles' and following-sibling::li='Sony Mobiles']"
This will return Nokia Mobiles and HTC Mobiles.

or
Xpath : "//ul/li[preceding-sibling::li[.='Apple Mobiles'] and following-sibling::li[.='Sony Mobiles']]"
Or You can use this in contains as well
Xpath: "//ul/li[preceding-sibling::li[contains(text(),'Apple Mobiles')] and following-sibling::li[contains(text(),'Sony Mobiles')]]"

80 comments:

  1. i have a question regarding xpath following -sibiling
    there is application(http://www.zlti.com/)in that menus are there which contain list links.i want to mouseover one menu and get all the list of liks and test those links by clicking .For that i need script.i have tried upto mouseover menu and perform clicking operation.But not able to finding list of links.pls give solution for that scenario.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. https://chrome.google.com/webstore/detail/relative-xpath-helper/eanaofphbanknlngejejepmfomkjaiic

    ReplyDelete
  4. A nice article here, i think that people who have grown up with the idea of using computers are showing more responsibility towards writing posts that are thoughtful, do not have grammar mistakes and pertinent to the post..

    Selenium Training in Chennai

    ReplyDelete
  5. This is very informative blog and article thank you for sharing with us keep posting more information about salesforce trainingselenium training, selenium online training, selenium course,learn selenium course

    ReplyDelete
  6. A fantastic blog to know what Selenium is all about. It can be used in combination with many basic core programming languages for testing applications. Selenium online training in hyderabad, best selenium online course

    ReplyDelete
  7. thanks for sharing topic on How to use preceding-sibling really very useful post keep sharing

    Selenium Training in Chennai

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

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

    http://thecreatingexperts.com/selenium-training-in-chennai/

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

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

    ReplyDelete
  9. I have been surfing the internet for the past three hours and I have not come across such a site. It has not only a good design but also great content. I have learned a lot and I will nit mind visiting this site to read both new and old articles. Find time and read my article by clicking on Cheap Essay Writing Services.

    ReplyDelete
  10. very informative blog with chapters covering SELENIUM, take a look at the link provided below to get hands on training with real time scenarios

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact info - 8122241286

    ReplyDelete
  11. nice blog has been shared by you.before i read this blog i didn't have any knowledge about this but now i got some knowledge. so keep on sharing such kind of an interesting blogs.
    selenium training in chennai

    ReplyDelete
  12. 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

    ReplyDelete
  13. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

    Online Robot Framework Training

    ReplyDelete
  14. You made such a fascinating piece to peruse, giving each subject illumination for us to grab learning. A debt of gratitude is for imparting the such data to us to peruse thisdevice testing manual

    ReplyDelete
  15. Very Very Nice Explanation.Really Thanks For Posting On Selenium Course

    ReplyDelete
  16. Thanks for the explanation.it was very clear to understand and looking forward for more updates on this topic. RPA training

    ReplyDelete
  17. Do you have a spam issue on this website; I also am a blogger, and I wanted to know your situation; many of us have developed some nice methods, and we are looking to trade methods with others, why not shoot me an e-mail if interested.
    Hadoop Training in Bangalore
    Hadoop Training in Chennai

    ReplyDelete
  18. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    MEAN stack training in Chennai
    MEAN stack training in bangalore

    ReplyDelete
  19. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.

    python training in chennai | python training in bangalore

    python online training | python training in pune

    python training in chennai

    ReplyDelete
  20. I would assume that we use more than the eyes to gauge a person's feelings. Mouth. Body language. Even voice. You could at least have given us a face in this test.
    python training in chennai
    python training in chennai
    python training in Bangalore

    ReplyDelete
  21. UiPath Training in Bangalore by myTectra is one the best UiPath Training. myTectra is the market leader in providing Robotic Process Automation on UiPath
    ui path training in bangalore

    ReplyDelete
  22. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Best Training Instittue


    ReplyDelete
  23. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    Best Training and Real Time Support

    Android Training From India

    Appium Training From India

    ReplyDelete
  24. I would assume that we use more than the eyes to gauge a person's feelings. Mouth. Body language. Even voice. You could at least have given us a face in this test.
    python online training
    python training in OMR
    python training course in chennai

    ReplyDelete
  25. After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.

    angularjs

    Training in chennai


    angularjs-Training in chennai

    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    ReplyDelete
  26. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    python Training in Bangalore | python Training in Bangalore

    ReplyDelete
  27. Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this.
    Golden gate Training Classes

    ReplyDelete
  28. It's really a nice experience to read your post. Thank you for sharing this useful information. If you are looking for more about It's really a nice experience to read your post. Thank you for sharing this useful information. If you are looking for more about

    ReplyDelete
  29. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
    No.1 AWS Training in Chennai | Amazon Web Services Training Institute in Chennai
    Best AWS Training Institute in Bangalore | Amazon Web Services AWS Training in Bangalore
    AWS Online Training | Online AWS Certification Training Course

    ReplyDelete
  30. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
    No.1 AWS Training in Chennai | Amazon Web Services Training Institute in Chennai
    Best AWS Training Institute in Bangalore | Amazon Web Services AWS Training in Bangalore
    AWS Online Training | Online AWS Certification Training Course

    ReplyDelete
  31. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
    No.1 AWS Training in Chennai | Amazon Web Services Training Institute in Chennai
    Best AWS Training Institute in Bangalore | Amazon Web Services AWS Training in Bangalore
    AWS Online Training | Online AWS Certification Training Course

    ReplyDelete
  32. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
    No.1 AWS Training in Chennai | Amazon Web Services Training Institute in Chennai
    Best AWS Training Institute in Bangalore | Amazon Web Services AWS Training in Bangalore
    AWS Online Training | Online AWS Certification Training Course

    ReplyDelete
  33. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTM, Marathahalli
    AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR

    ReplyDelete
  34. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTM, Marathahalli
    AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR

    ReplyDelete
  35. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    RPA training in bangalore
    rpa training in chennai

    ReplyDelete
  36. This comment has been removed by the author.

    ReplyDelete
  37. Thanks for shraing this blog..i love this article.. I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post.
    selenium online training in hyderabad

    ReplyDelete
  38. Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.


    apple iphone service center in chennai | apple ipad service center in chennai | apple iphone service center in chennai

    ReplyDelete
  39. Just stumbled across your blog and was instantly amazed with all the useful information that is on it. Great post, just what i was looking for and i am looking forward to reading your other posts soon!
    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  40. How can i return following and preceding sibling together i.e based on some condition i got 'Nokia Mobiles' then it should return { HTC Mobiles, Sony Mobiles, Micromax mobiles and Samsung mobiles}

    ReplyDelete
  41. Looking for JOB in core industry? We're offering additional discount on early enrollment on full module Automation Training. Certificate will be given to those who completed their training and also get 100% Job assistance(Life Time).Call 9953489987, 9711287737.

    ReplyDelete
  42. Great article with very unique and useful information,,,
    Thank you,,,,Keep Updating,,,

    Power BI Online Training Hyderabad

    ReplyDelete
  43. https://cloudn1n3.blogspot.com/2014/12/a-look-at-simplivity-hyper-convergence.html?showComment=1610879487698#c8366420918885666291

    ReplyDelete
  44. Title:
    Best Java Training Institute in Chennai | Infycle Technologies

    Description:
    Practice Java for making your career towards a sky-high with Infycle Technologies. Infycle Technologies is the best Java training institute in Chennai, providing courses for the Java certification in Chennai in 200% hands-on practical training with professional trainers in the domain. Apart from the training, the placement interviews will be arranged for the students to set their careers without any struggle. Of all that, 100% placement assurance will be given here. To have the best job, call 7502633633 to Infycle Technologies and grab a free demo to know more.
    Best training in Chennai

    ReplyDelete
  45. Infycle Technologies, the No.1 software training institute in Chennai offers the Selenium course in Chennai for tech professionals, freshers, and students at the best offers. In addition to the Selenium, other in-demand courses such as Python, Big Data, Oracle, Java, Python, Power BI, Digital Marketing, Cyber Security also will be trained with hands-on practical classes. After the completion of training, the trainees will be sent for placement interviews in the top companies. Call 7504633633 to get more info and a free demo.

    ReplyDelete
  46. Title:
    Description:
    Are you looking for Big Data training in Chennai with placement opportunities? Then we, Infycle Technologies are with you to make your dream into reality. Infycle Technologies is one of the best Big Data Training Institute in Chennai, which offers various programs along with Big Data such as Oracle, Java, AWS, Hadoop, etc., in complete hands-on practical training with trainers, those are specialists in the field. In addition to the training, the mock interviews will be arranged for the candidates, so that they can face the interviews with the best knowledge. Of all that, 100% placement assurance will be given here. To have the words above in the real world, call 7502633633 to Infycle Technologies and grab a free demo to know more.

    best training institute in chennai

    ReplyDelete
  47. Auto Detail School is the only private licensed exclusiveAuto Detail School, in which their programs are exclusively for auto detailing. Visit here now!

    ReplyDelete