0

I'm trying to click on a button:

<button type="submit" class="btn__primary--large" data-cie-control-urn="checkpoint_remember_me_save_info_yes">Remember</button>

I tried driver.find_element(By.XPATH("//span/button[text()='Remember'][1]")).click() But got the following error: TypeError: 'str' object is not callable.

Also tried driver.find_element_by_xpath("//span[contains(text(), 'btn__primary--large')]").click() but no click has been made and got the error: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span[contains(text(), 'btn__primary--large')]"}

asked Apr 21, 2021 at 8:46
3
  • Can you provide the link to the web page to see what the correct locator of the element you are looking for? Commented Apr 21, 2021 at 8:49
  • The url is linkedin.com/checkpoint/lg/login-submit and its coming up after a succefull login from the url: linkedin.com/login Commented Apr 21, 2021 at 8:51
  • OK, I see the element there. The xpath I gave you previously in my answer is correct Commented Apr 21, 2021 at 8:54

2 Answers 2

1

Try //button[@data-cie-control-urn='checkpoint_remember_me_save_info_yes'] xpath

answered Apr 21, 2021 at 8:48

2 Comments

I get the error 'TypeError: 'str' object is not callable, from the following line: driver.find_element(By.XPATH("//button[@data-cie-control-urn='checkpoint_remember_me_save_info_yes']")).click()
Maybe you should add some delay to let the element completely loaded before clicking on it?
0

I dont know why driver.find_element(By.XPATH("//button[@data-cie-control-urn='checkpoint_remember_me_save_info_yes']")).click() didnt worked,

but driver.find_element_by_xpath("//button[@data-cie-control-urn='checkpoint_remember_me_save_info_yes']").click() works like a charm.

answered Apr 21, 2021 at 9:21

2 Comments

What's because I sent you a Java code while you are using Python :)
No, it was even not my fault. I sent you xpath only. Anyway, I'm happy it helped you. So, if possible, accept my answer

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.