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,320 points
20,852 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,910 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
7,335 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 29, 2018 in Selenium by bug_seeker
• 15,510 points
1,952 views
0 votes
2 answers

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,500 points
13,767 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,186 views
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,910 points
7,260 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,898 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
17,831 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP