<html>
<head><title>Selenium webdriver - Selecting checkbox based on table value or specific value</title>
</head>
<body>
<table border=2>
<tr>
<td>Nash</td>
<td><input type="checkbox" id="N"/></td>
</tr>
</table>
</body>
</html>
Selenium-Code
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SelectSpecificCheckBox
{
public static void main(String[] args)
{
WebDriver driver=new FirefoxDriver();
driver.get("E:\\Practice Example\\TableCheckbox.htm");
driver.findElement(By.xpath("//td[contains(text(),'Nash')]/following-sibling::td/input[@id='N']")).click();
driver.close();
}
}
1 Comments
Helpful Article with good explation
ReplyDelete