Skip to content

Commit 50bf895

Browse files
getting text from a sibling node and printing it to the console
1 parent 0ea2502 commit 50bf895

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package src;
2+
3+
import org.openqa.selenium.By;
4+
import org.openqa.selenium.WebDriver;
5+
import org.openqa.selenium.WebElement;
6+
import org.openqa.selenium.chrome.ChromeDriver;
7+
8+
import java.util.concurrent.TimeUnit;
9+
10+
public class XPathSiblingNodes {
11+
12+
public static void main(String[] args) {
13+
14+
WebDriver driver = new ChromeDriver();
15+
String baseURL = "https://learn.letskodeit.com/p/practice";
16+
driver.manage().window().maximize();
17+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
18+
driver.get(baseURL);
19+
20+
WebElement price = driver.findElement(By.xpath("//td[text()='Python Programming Language']//following-sibling::td"));
21+
// printing price of the book "Python Programming Language" to the console
22+
System.out.println(price.getText());
23+
24+
25+
}
26+
27+
}

0 commit comments

Comments
 (0)