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,220 points
4,647 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,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
530 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,310 points
118 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,050 points
260 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
629 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
257 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,508 views
0 votes
2 answers

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
10,912 views