Search code examples
pythonseleniumselenium-webdriverwebdriverwebdriverwait

AttributeError: type object 'By' has no attribute 'name'


I'm doing a selenium program that can enter to my email, but I'm having problems with a By, and it cannot be By.name("") or that seems.

Here is the mentioned part of the code: (running on windows 7):

psswd = WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.name, "password")))
psswd.send_keys("MyPassword")

Solution

  • You were almost there. You need to make a simple change as follows:

    • You need to replace name with NAME

    Effectively, your line of code will be:

    psswd = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.NAME, "password")))
    psswd.send_keys("MyPassword")