0

How do I click a checkbox with Selenium Python, if I don't have any id which defines the checkbox?

2
  • Is ID the only way to identify an element? Have to tried any other of the available methods? Commented Jul 10, 2015 at 17:20
  • Kate's link appears to solve the problem. If it doesn't, please edit and explain why, and we'll reopen this.
    – corsiKa
    Commented Jul 16, 2015 at 17:37

2 Answers 2

0

Although an id is by far the easiest, there are many other options to locate an element on the page.

All provided alternatives are listed here, with examples: http://selenium-python.readthedocs.org/en/latest/locating-elements.html

1
  • 3
    It would be better if you list down the options for location elements here and then give a reference link. That way if the referenced link or the complete website is taken down, the answer will still be available here for user to solve their problem. Commented Jul 11, 2015 at 3:19
0

You can opt from a range of locating mechanisms- apart from id. You can use the name, the xpath, the css, tagname, etc. for locating a webelement.

Here is a detailed tutorial about locating mechanisms

http://www.guru99.com/locators-in-selenium-ide.html

EDIT : Here is an example where you can use Xpath to select the checkbox

AUT : Heroku App

You can select the checkboxes using xpath as :

driver.find_element_by_xpath('//*[@id='checkboxes']/input[1]')

or

driver.find_element_by_xpath('//*[@id='checkboxes']/input[2]')

Not the answer you're looking for? Browse other questions tagged or ask your own question.