-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWebTable.java
More file actions
43 lines (25 loc) · 901 Bytes
/
Copy pathWebTable.java
File metadata and controls
43 lines (25 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package chapter13;
import java.util.Iterator;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class WebTable {
public static void main(String[] args) throws InterruptedException {
ChromeDriver driver = new ChromeDriver();
driver.get("https://letcode.in/table");
WebElement table = driver.findElementByCssSelector("table#simpletable>tbody");
List<WebElement> rows = table.findElements(By.tagName("tr"));
System.out.println(rows.size());
for (int i = 0; i < rows.size(); i++) {
List<WebElement> cols = rows.get(i).findElements(By.tagName("td"));
WebElement data = cols.get(1);
System.out.println(data.getText());
if (data.getText().equals("Chatterjee")) {
cols.get(3).findElement(By.tagName("input")).click();
break;
}
}
driver.quit();
}
}