find submit button in selenium without id
There are many options here, to name a few:
If class alone is unique, you can use
driver.find_element_by_css_selector(".button_main").click()
If class + value combo is unique, you can use:
driver.find_element_by_css_selector(".button_main[value='something']").click()
You can also use xpath:
driver.find_element_by_xpath("//input[@type='submit' and @value='something']").click()
If none of those work (i.e. they are not identifying button uniquely), look at the elements above the button (for example <form
) and provide the xpath in format:
driver.find_element_by_xpath("//unique_parent//input[@type="submit" and @value='something']").click()
i recommend xpath chrome extension, with it you will be able to get the path by running the extension and shift-clicking on the element you want this chrome extension https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl