Python: find_element_by_css_selector

To click on the Login button you can use either of the the following line of code :

  • LinkText :

    driver.find_element_by_link_text("Login").click()
    
  • CssSelector :

    driver.find_element_by_css_selector("a.login-btn > span.btn-text").click()
    
  • Getting more granular with the CssSelector you can also use the following line of code :

    driver.find_element_by_css_selector("a.login-btn[data-bind='click:loginSection.loginClick'] > span.btn-text").click()
    

Update :
As you are seeing NoSuchElementException you can check this discussion

Leave a Comment