2

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 !

Bharat Mane
6,78512 gold badges42 silver badges69 bronze badges
asked Mar 22, 2019 at 2:32

1 Answer 1

0

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
3
  • 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 info Commented 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' Commented 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 :) Commented Mar 22, 2019 at 12:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.