Reputation: 1395
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
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.
To locate an element with id
attribute value using css_selector
we use #id
. So correct css_locator
with id
attribute value is :-
div.tm-control-group > button#btn-signin
To locate an element with other attribute value using css_selector
we use [attribute-name = 'attribute-value']
. So correct css_locator
with rel
attribute value is :-
div.tm-control-group > button[rel = 'btn-signin']
Upvotes: 1
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