Skip to content Skip to sidebar Skip to footer

How To Select 'username' Field On Website With Selenium Webdriver?

All I'm trying to do is enter a username and password... I tried: username=driver.find_element(By.CSS_SELECTOR('UserId')) username.send_keys('test') but it gave me the error: user

Solution 1:

The method find_element requires 2 arguments:

username=driver.find_element(By.NAME, "UserId")
username.send_keys("test")

You could also use find_element_by_name

username=driver.find_element_by_name("UserId")
username.send_keys("test")

Solution 2:

If you want to select by css selector, you'll have to use the correct css selector. You'll want something like this:

username=driver.find_element_by_css_selector('input[name="UserId"]')

Post a Comment for "How To Select 'username' Field On Website With Selenium Webdriver?"