1

I want to select a checkbox with the HTML code shown below using the attribute bayid:

<input type="checkbox" devid="bay" bayid="10" checked="">

I could get the XPath information - "//*[@id="svbSelectEnc1"]/table/tbody/tr[7]/td[3]/input", but I want to use the bayid for selecting as there are lot of checkboxes in the form of a table and only specific checkboxes have to be selected that are read from the config file.

3 Answers 3

1

You can achieve it by using CSS Selector or XPath as shown below.

By CSS Selector

driver.findElement(By.cssSelector("input[bayid='10']")).click();

By XPath

//input[@bayid='10']

Also I would suggest you to go through basic tutorial on how to find WebElement using CSS Selector and XPath

Sign up to request clarification or add additional context in comments.

Comments

0

try the following XPath:

//input[@bayid='10']

Comments

0

CSS selector way to do this:

driver.findElement(By.cssSelector("yourTagName[attribute='attributeValue']")).click();

For your specific case:

driver.findElement(By.cssSelector("input[bayid='10']")).click();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.