Home > Enterprise >  Python Selenium. Can't click a button
Python Selenium. Can't click a button

Time:08-15

I'm trying to click the "Sign In" button, but I get various errors, like:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="Sign In"]"}

Here's the link: https://e.pilkington.com/ecomm/search/tools

-Code Snippet-

login_button = driver.find_element('name','Sign In')
login_button.submit()

Code works for a another site so syntax is correct. I know that button's name isn't 'Sign In', but I tried various options like 'linkText' and nothing works. Can someone help me? Thanks in adavance.

CodePudding user response:

Try using Xpath instead of Name.

login_button =driver.find_element_by_xpath("//button[text()='Sign In']")
login_button.submit()
  • Related