title: How to send text to the Password field using Selenium and Python
body: <p>Selenium with Chromedriver Python: Unable to locate element: {&quot;method&quot;:&quot;cs s selector&quot;,&quot;selector&quot;:&quot;[id=&quot;password&quot;]&quot;}</p>
  <p>I edited the question to says, it works well when using the chrome browser, but the same code fails in --headless mode (which is what I want to use)</p>
  <p>I have been scratching my head over the past week with this issue:
  Chromedriver cannot find the <em>presence_of_element_located((By.ID, 'password'))</em>, although it is clearly there as seen in the screenshot.
  It finds the username by the same By.ID and inputs it correctly, but when it gets to thew password, it fails.</p>
  <p>[****@mtlab-auto tmp]$ google-chrome --version</p>
  <p>Google Chrome 83.0.4103.106</p>
  <p>headless chrome=83.0.4103.106</p>
  <p>Python 3.8.0 (default, May  7 2020, 02:49:39)</p>
  <pre><code>    ########### Chrome option  ###############
  chromeOptions = webdriver.ChromeOptions()
  
  chromeOptions.add_argument('--headless')
  chromeOptions.add_argument('window-size=1920,1080')
  chromeOptions.add_argument('start-maximized')
  chromeOptions.add_argument('disable-infobars')
  
  prefs = {'download.default_directory' : f'{temp_folder}'}
  chromeOptions.add_experimental_option('prefs',prefs)
  
  # capabilities = DesiredCapabilities.CHROME.copy()
  # capabilities['acceptSslCerts'] = True 
  # capabilities['acceptInsecureCerts'] = True
  
  ############# Set chrome proxy ###########
  Chrome_Proxy = 'http://135.28.13.11:8888'
  #Chrome_Proxy = 'http://autoproxy.sbc.com/autoproxy.cgi'
  chromeOptions.add_argument('--proxy-server=%s' % Chrome_Proxy)
  
  ############### Enable chrome browser wedriver ##############
  browser = webdriver.Chrome(executable_path='/home/dev/chromedriver', options=chromeOptions,\
  service_args = [f'--log-path={chromeDriver_log}'])
  
  # browser = webdriver.Chrome(executable_path='/home/dev/chromedriver', options=chromeOptions,\
  # desired_capabilities = capabilities, service_args = [f'--log-path={chromeDriver_log}'])
  
  ############## Set the timeout values ###############
  ignored_exceptions = (NoSuchElementException,StaleElementReferenceException)
  #browser.set_page_load_timeout(15)
  #browser.implicitly_wait(40)
  element_timeout = 30
  print()
  print(Fore.BLUE + '&gt;&gt;&gt; Accessing Cisco Cloud...')
  
  browser.get(r'https://slexui.cloudapps.cisco.com/SWIFT/LicensingUI/Quickstart')
  
  time.sleep(20)
  browser.get_screenshot_as_file('/tmp/main-page.png')
  
  try:
      element_login = EC.presence_of_element_located((By.ID, 'login-button'))
      WebDriverWait(browser, element_timeout).until(element_login)
  
  except TimeoutException:
      print(Fore.RED + 'Fail to load login page')
      print('RC=101,&quot;Error: Failed to load Cisco Website&quot;')
      browser.close()
      quit()
  
  print()
  print(browser.title)
  print()
  
  ######### Login to cisco cloud account ###########
  print(Fore.BLUE + ' &gt;&gt;&gt; Login to Cisco Cloud')
  
  ######################## Username ##################
  try:
      element_username = EC.presence_of_element_located((By.ID, 'userInput'))
      WebDriverWait(browser, element_timeout).until(element_username).send_keys(f'{cisco_userid}')
  
  except TimeoutException:
      print(Fore.RED + 'Fail to load login page')
      print('RC=101,&quot;Error: Failed to login to Cisco Website&quot;')
      browser.close()
      quit()
  
  time.sleep(2)
  #browser.find_element_by_id('userInput').send_keys(f'{cisco_userid}')
  print('&gt;&gt;&gt;&gt; Username input')
  browser.find_element_by_id('login-button').click()
  
  time.sleep(20)
  browser.get_screenshot_as_file('/tmp/password.png')
  
  ###################### Password ##################
  try:
      element_password = EC.presence_of_element_located((By.ID, 'password'))
      WebDriverWait(browser, element_timeout).until(element_password).send_keys(f'{cisco_password}')
  
  except TimeoutException:
      print(Fore.RED + 'Timed out waiting for page to load')
      print('RC=101,&quot;Error: Failed to login to Cisco Website&quot;')
      browser.close()
      quit()
  
  time.sleep(5)
  #browser.find_element_by_id('password').send_keys(f'{cisco_password}')
  print('&gt;&gt;&gt;&gt; Password input')
  browser.find_element_by_id('kc-login').click()
  
  ############# Check if we are logged in #############
  </code></pre>
  <p>And here is the log: it finds my username and puts in the correct username, but fails at the password field. I took a screenshot right after I enter my username, and you can clearly see the password field and nothing is found by chromedriver</p>
  <pre><code>[1592922143.110][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND Navigate {
     &quot;url&quot;: &quot;https://slexui.cloudapps.cisco.com/SWIFT/LicensingUI/Quickstart&quot;
  }
  [1592922143.110][INFO]: Waiting for pending navigations...
  [1592922143.111][INFO]: Done waiting for pending navigations. Status: ok
  [1592922168.003][INFO]: Waiting for pending navigations...
  [1592922243.956][INFO]: Done waiting for pending navigations. Status: ok
  [1592922243.956][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE Navigate
  [1592922263.980][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND Screenshot {
  
  }
  [1592922263.980][INFO]: Waiting for pending navigations...
  [1592922263.982][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.304][INFO]: Waiting for pending navigations...
  [1592922264.305][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.305][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE Screenshot &quot;iVBORw0KGgoAAAANSUhEUgAAB4AAAAQ4CAYAAADo08FDAAAAAXNSR0IArs4c6Q
  AAIABJREFUeJzs3XecnWWZN/DfmTnTMsmkzARCEpDQErq0QABBREEhSHEtKJaAq7irK7Iq+y7i6loWQRfbWt5XkSILWEFBikgRCIjSCaFICAgJ6clMMpPp7x+DE0ISQpKBgYfv9...&quot;
  [1592922264.309][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[id=\&quot;login-button\&quot;]&quot;
  }
  [1592922264.309][INFO]: Waiting for pending navigations...
  [1592922264.310][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.329][INFO]: Waiting for pending navigations...
  [1592922264.330][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.330][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE FindElement {
     &quot;element-6066-11e4-a52e-4f735466cecf&quot;: &quot;0db6e420-49df-46ab-9939-b2f471f9d919&quot;
  }
  [1592922264.331][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND GetTitle {
  
  }
  [1592922264.331][INFO]: Waiting for pending navigations...
  [1592922264.332][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.335][INFO]: Waiting for pending navigations...
  [1592922264.336][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.336][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE GetTitle &quot;Cisco.com Login Page&quot;
  [1592922264.337][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[id=\&quot;userInput\&quot;]&quot;
  }
  [1592922264.337][INFO]: Waiting for pending navigations...
  [1592922264.338][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.355][INFO]: Waiting for pending navigations...
  [1592922264.356][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.356][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE FindElement {
     &quot;element-6066-11e4-a52e-4f735466cecf&quot;: &quot;72de3929-e23d-436c-ab22-adb6e79109bd&quot;
  }
  [1592922264.357][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND TypeElement {
     &quot;id&quot;: &quot;72de3929-e23d-436c-ab22-adb6e79109bd&quot;,
     &quot;text&quot;: &quot;an144a001&quot;,
     &quot;value&quot;: [ &quot;*&quot;, &quot;*&quot;, &quot;*&quot;, &quot;*&quot;, &quot;*&quot;, &quot;*&quot;, &quot;0&quot;, &quot;0&quot;, &quot;1&quot; ]
  }
  [1592922264.357][INFO]: Waiting for pending navigations...
  [1592922264.358][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.496][INFO]: Waiting for pending navigations...
  [1592922264.497][INFO]: Done waiting for pending navigations. Status: ok
  [1592922264.497][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE TypeElement
  [1592922266.502][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[id=\&quot;login-button\&quot;]&quot;
  }
  [1592922266.502][INFO]: Waiting for pending navigations...
  [1592922266.504][INFO]: Done waiting for pending navigations. Status: ok
  [1592922266.517][INFO]: Waiting for pending navigations...
  [1592922266.518][INFO]: Done waiting for pending navigations. Status: ok
  [1592922266.518][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE FindElement {
     &quot;element-6066-11e4-a52e-4f735466cecf&quot;: &quot;0db6e420-49df-46ab-9939-b2f471f9d919&quot;
  }
  [1592922266.521][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND ClickElement {
     &quot;id&quot;: &quot;0db6e420-49df-46ab-9939-b2f471f9d919&quot;
  }
  [1592922266.521][INFO]: Waiting for pending navigations...
  [1592922266.522][INFO]: Done waiting for pending navigations. Status: ok
  [1592922266.622][INFO]: Waiting for pending navigations...
  [1592922266.624][INFO]: Done waiting for pending navigations. Status: ok
  [1592922266.624][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE ClickElement
  [1592922286.634][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND Screenshot {
  
  }
  [1592922286.634][INFO]: Waiting for pending navigations...
  [1592922286.636][INFO]: Done waiting for pending navigations. Status: ok
  [1592922287.079][INFO]: Waiting for pending navigations...
  [1592922287.080][INFO]: Done waiting for pending navigations. Status: ok
  [1592922287.080][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE Screenshot &quot;iVBORw0KGgoAAAANSUhEUgAAB4AAAAQ4CAYAAADo08FDAAAAAXNSR0IArs4c6Q
  AAIABJREFUeJzs3XmYnFWdL/BvVVd3p7uTzk72QAiBQFiCsqNsAVzhDoIoijqIo86AOnp1HK+z4DIzOug4V8dt0FHwKqCAsiggKosgEER22RMEAiEL2Tvpte4fkQ6dfemk4OXze...&quot;
  [1592922287.087][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[name=\&quot;password\&quot;]&quot;
  }
  [1592922287.087][INFO]: Waiting for pending navigations...
  [1592922287.088][INFO]: Done waiting for pending navigations. Status: ok
  [1592922287.109][INFO]: Waiting for pending navigations...
  [1592922287.110][INFO]: Done waiting for pending navigations. Status: ok
  [1592922287.110][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE FindElement ERROR no such element: Unable to locate element: {&quot;method&quot;:&quot;cs
  s selector&quot;,&quot;selector&quot;:&quot;[name=&quot;password&quot;]&quot;}
    (Session info: headless chrome=83.0.4103.106)
  [1592922287.614][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[name=\&quot;password\&quot;]&quot;
  }
  [1592922287.614][INFO]: Waiting for pending navigations...
  [1592922287.615][INFO]: Done waiting for pending navigations. Status: ok
  [1592922287.628][INFO]: Waiting for pending navigations...
  [1592922287.629][INFO]: Done waiting for pending navigations. Status: ok
  [1592922287.629][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE FindElement ERROR no such element: Unable to locate element: {&quot;method&quot;:&quot;cs
  s selector&quot;,&quot;selector&quot;:&quot;[name=&quot;password&quot;]&quot;}
    (Session info: headless chrome=83.0.4103.106)
  [1592922288.132][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[name=\&quot;password\&quot;]&quot;
  }
  [1592922288.132][INFO]: Waiting for pending navigations...
  [1592922288.133][INFO]: Done waiting for pending navigations. Status: ok
  [1592922288.145][INFO]: Waiting for pending navigations...
  [1592922288.146][INFO]: Done waiting for pending navigations. Status: ok
  [1592922288.146][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE FindElement ERROR no such element: Unable to locate element: {&quot;method&quot;:&quot;cs
  s selector&quot;,&quot;selector&quot;:&quot;[name=&quot;password&quot;]&quot;}
    (Session info: headless chrome=83.0.4103.106)
  [1592922288.649][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[name=\&quot;password\&quot;]&quot;
  }
  [1592922288.649][INFO]: Waiting for pending navigations...
  [1592922288.650][INFO]: Done waiting for pending navigations. Status: ok
  [1592922288.662][INFO]: Waiting for pending navigations...
  [1592922288.663][INFO]: Done waiting for pending navigations. Status: ok
  [1592922288.663][INFO]: [cb94f02b714bfe0ce21b3dac35546605] RESPONSE FindElement ERROR no such element: Unable to locate element: {&quot;method&quot;:&quot;cs
  s selector&quot;,&quot;selector&quot;:&quot;[name=&quot;password&quot;]&quot;}
    (Session info: headless chrome=83.0.4103.106)
  [1592922289.166][INFO]: [cb94f02b714bfe0ce21b3dac35546605] COMMAND FindElement {
     &quot;using&quot;: &quot;css selector&quot;,
     &quot;value&quot;: &quot;[name=\&quot;password\&quot;]&quot;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/peymv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/peymv.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/5qTl0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5qTl0.jpg" alt="enter image description here" /></a></p>