Sultan Morbiwala
Sultan Morbiwala

Reputation: 171

Error in python code, not sure how to solve it?

I am using selenium with webdriver for login on a particular website but got stuck in the middle. The error comes when it starts to type email address.

Code is below:-

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://society6.com/login?done=/")
username = driver.find_element_by_id('email').click()
username.send_keys("[email protected]")
password = driver.find_element_by_id('password').click()
password.send_keys("abcd")
button = driver.find_element_by_name('login').click()

Error - username.send_keys("[email protected]")
AttributeError: 'NoneType' object has no attribute 'send_keys'

the mouse is clicking on the textbox but its not typing what mistake am i doing here?

Upvotes: 0

Views: 55

Answers (1)

MarianD
MarianD

Reputation: 14121

Your error means, that the username has the None value.

That in turn means, that your command

username = driver.find_element_by_id('email').click()

returns None.

Why?

Because the .click() method returns None.

So, split that command into these two:

username = driver.find_element_by_id('email')
username.click()

Upvotes: 2

Related Questions