Selenium webdriver - Selecting checkbox based on table value or specific value


HTML Page


<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();
}


}

Post a Comment

1 Comments

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)