I have this HTML code:
<button> class="btn btn-lg btn-primary btn-block"
type="submit">Autentificare</button>
input type="hidden" name="next" value="/"/
Using below locator I'm not able to click on that button.
elem.find_element_by_link_text("Autentificare")
Can someone please help me out !
1 Answer 1
A <button></button>
HTML tag is not the same as a link <a></a>
. So it cannot find it with the find_element_by_link_text()
method, because it looks for link HTML tags.
If you want to find elements by text try the following:
driver.find_elements_by_xpath("//*[contains(text(), 'Autentificare')]")
answered Mar 22, 2019 at 8:26
-
now im stuck at this: driver.find_elements_by_xpath("//*[contains(text(), 'Autentificare')]").sendKeys(Keys.ENTER) . i cant manage to send the enter key in order to send the login infoAlex Alex– Alex Alex2019年03月22日 11:57:56 +00:00Commented Mar 22, 2019 at 11:57
-
this is the error driver.find_elements_by_xpath("//*[contains(text(), 'Autentificare')]").sendKeys(Keys.ENTER) AttributeError: 'list' object has no attribute 'sendKeys'Alex Alex– Alex Alex2019年03月22日 12:02:24 +00:00Commented Mar 22, 2019 at 12:02
-
@AlexAlex You cannot send text to a button, you need to send text to an input. This sounds as another question, because your original question is about clicking. If the clicking works, accept the answer and ask a new question for the new issues :)Niels van Reijmersdal– Niels van Reijmersdal2019年03月22日 12:26:51 +00:00Commented Mar 22, 2019 at 12:26
Explore related questions
See similar questions with these tags.
default