Virendra Joshi
Virendra Joshi

Reputation: 479

Need Xpath or CSSSelector locator for below HTML Code for a checkbox element

Need help with Xpath or CSSSelector locator for below HTML Code for a checkbox element. Checkbox element is present on the webpage with below URL : https://www.seleniumeasy.com/test/basic-checkbox-demo.html

<div class="checkbox">
<label>
<input type="checkbox" class="cb1-element" value="">Option 1</label>
</div>

Upvotes: 0

Views: 44

Answers (2)

Sooraj
Sooraj

Reputation: 585

Xpath:

//label[text()='Option 1']/input

Upvotes: 1

Māris L
Māris L

Reputation: 37

I'm using Python, so in my case would look like this if I would use XPath:

driver.find_element_by_xpath("//label[contains(.,'Option 1')]").click()

You can do like this if your page contains only one Option 1 text

Upvotes: 0

Related Questions