iNoob
iNoob

Reputation: 1395

Selenium, clicking buttons

I am having a hard time working out how to 'click' on this button using Seleniumn's ChromeDriver. I have attempted using the css_selector like so

submit_button = browser.find_elements_by_css_selector('div.tm-control-group > btn-signin')

Source

<div class="tm-control-group">
<button class="tm-btn tm-btn-danger l10n login-info" type="button" rel="btn_signin" id="btn-signin">Log On</button>

Upvotes: 0

Views: 51

Answers (2)

Saurabh Gaur
Saurabh Gaur

Reputation: 23835

div.tm-control-group > btn-signin

This css_selector would locate <btn-signin> element which has parent element as <div class = 'tm-control-group'> while you want to locate <button> element.

Actually btn-signin is value of id and rel attributes of the <button> element.

Upvotes: 1

alecxe
alecxe

Reputation: 474191

The div.tm-control-group > btn-signin would try to search btn-signin element, while you are looking for the button element instead. Either change the selector to:

div.tm-control-group > button

Or, even better, just locate the button by id:

button#btn-signin

Or, via:

driver.find_element_by_id("btn-signin")

Upvotes: 2

Related Questions