How to get next sibling element using XPath and Selenium for Java?

0 votes

Getting a parent element when using Selenium for Java and XPath is something like this

WebElement parent = child.findElement(By.xpath(".."));

But how do I get the next sibling of an element?

May 15, 2018 in Selenium by Martin
• 4,210 points
3,748 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Below code will help you:

Try following-sibling axis :

WebElement followingSibling = child.findElement(By.xpath("following-sibling::*"));

List of available axes by MDN, for further reference : Mozilla Developer Network : Axes

answered May 15, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to disable cookies using webdriver for Chrome and FireFox JAVA?

The solution for Firefox is below: FirefoxProfile profile ...READ MORE

answered Aug 8, 2018 in Selenium by Meci Matt
• 9,400 points
401 views
0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 28, 2018 in Selenium by bug_seeker
• 14,970 points
87 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,030 points
65 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
438 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
51 views
0 votes
1 answer

How to test React JS dropdown with Selenium and java?

Below code will help you: Actions act = ...READ MORE

answered May 14, 2018 in Selenium by Samarpit
• 5,130 points
2,033 views
0 votes
1 answer

How to get HTML Source of WebElement in Selenium WebDriver using Python?

You can read innerHTML attribute to get source of ...READ MORE

answered Jun 13, 2018 in Selenium by Samarpit
• 5,130 points
7,799 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.