-1

How can I find the log in button element? My script as below but not working after input username & password. Or shall I use find element by css selector or other? and how?

driver.find_element_by_name("username").send_keys(username)
driver.find_element_by_name("password").send_keys(password)
driver.find_element_by_class_name("cux-button ng-scope").click()

enter image description here

Aniket Tiratkar
  • 798
  • 6
  • 16
GeorgeW
  • 23
  • 3

1 Answers1

1

I assume that you are using Selenium and the Selenium Python bindings. (Tipp: Mention the library, you are using, in your question. :) )

The find_element_by_class_name() method only allows searching for a single class name, as already discussed in this question. As mentioned in the answers to that question, you can use the find_element_by_xpath() or find_element_by_css_selector() methods for more complex queries.

In your scenario, CSS selectors are sufficiently powerfull, so let's use them:

driver.find_element_by_css_selector(".cux-button.ng-scope").click()

For understanding CSS selectors, you might want to take a look into this tutorial by Sauce Labs, as recommended by the unofficial Python Selenium docs.

mhthies
  • 113
  • 9