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
5,495 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,420 points
686 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,350 points
168 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,090 points
567 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
895 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
559 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 in Selenium by ghoshPooja
• 140 points
2,995 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
13,832 views