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,330 points
10,533 views

1 answer to this question.

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,870 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,460 points
2,019 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
• 15,390 points
487 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,510 points
2,864 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,870 points
2,221 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,870 points
2,335 views
0 votes
2 answers

How to test React JS dropdown with Selenium and java?

First of all you need to click ...READ MORE

answered Aug 20, 2019 in Selenium by ghoshPooja
• 140 points
6,168 views
0 votes
2 answers