1

I wish to enter username and password on the following site

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Chrome()
browser.get('https://baud.teamwork.com/launchpad/login?continue=%2Fcrm')
username = driver.find_element_by_id("loginemail")
username.send_keys("YourUsername")

I tried changing

driver.find_element_by_name

and still doesn´t work

I get the following error:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"name","selector":"loginemail"}
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Lucas
  • 549
  • 1
  • 4
  • 16

3 Answers3

2

To send a character sequence within the Email address filed you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    driver.get("https://baud.teamwork.com/launchpad/login?continue=%2Fcrm")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#loginemail"))).send_keys("lucas@stackoverflow.com")
    
  • Using XPATH:

    driver.get("https://baud.teamwork.com/launchpad/login?continue=%2Fcrm")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='loginemail']"))).send_keys("lucas@stackoverflow.com")
    
  • Note : You have to add the following imports:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

baud


References

You can find a couple of relevant discussions on NoSuchElementException in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
1

Try changing this:

username = driver.find_element_by_id("loginemail")

into this:

username = browser.find_element_by_id("loginemail")

Or the entire code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Chrome()
browser.get('https://baud.teamwork.com/launchpad/login?continue=%2Fcrm')
username = browser.find_element_by_id("loginemail")
username.send_keys("YourUsername")
1
Even if your locators correct selenium could not identify , because you need to wait for that element then only you can do some actions 

use this line before username locator line.(but thread sleep does not use nowadays because of time consuming ,if we use thread sleep (3000) our execution script line will delay for 3 sec )

    browser = webdriver.Chrome()
browser.get('https://baud.teamwork.com/launchpad/login?continue=%2Fcrm')
**Thread.sleep(3000);**
username = driver.find_element_by_id("loginemail")
username.send_keys("YourUsername")



Best way is please use Webdriver wait in selenium
Justin Lambert
  • 940
  • 1
  • 7
  • 13