Selen through Python doesn't populate field

I am trying to use Selenium through Python to populate a username and password field to allow Twitter authorization. This should be a very simple task, but it continues to give me an error. Here's the HTML username field I want to populate:

<div class="row user ">
  <label for="username_or_email" tabindex="-1">Username or email</label>
  <input aria-required="true" autocapitalize="off" autocorrect="off" autofocus="autofocus" class="text" id="username_or_email"  name="session[username_or_email]" type="text" value="">
</div>

Here's the HTML code for the password field:

<div class="row password ">
  <label for="password" tabindex="-1">Password</label>
  <input aria-required="true" class="password text"  id="password" name="session[password]" type="password" value="">
</div>

Here is my code:

username_field = browser.find_element_by_id("username_or_email") 
password_field = browser.find_element_by_id("password")
username_field.send_keys("MyEmail@gmail.com")
password_field.send_keys("SuperSecretPassword")
password_field.send_keys(Keys.ENTER)

Pretty simple? But at the moment when I run the code, it gives an error message when it tries to send_keys at the end of the error:

selenium.common.exceptions.WebDriverException: Message: TypeError - undefined is not a function (evaluating '_getTagName(currWindow).toLowerCase()')

Can someone explain to me what is going on here? Why does he refuse to fill in the fields?

+4
source share
1 answer

, script

, webdriver

chromedriver 2.25

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


driver = webdriver.Chrome(executable_path="/home/user/selenium/chromedriver2.25")
url = 'http://localhost/teste.html'
driver.get(url)

username_field = driver.find_element_by_id('username_or_email')
password_field = driver.find_element_by_id("password")


username_field.send_keys("MyEmail@gmail.com")
password_field.send_keys("SuperSecretPassword")

password_field.send_keys(Keys.ENTER)

HTML:

<div class="row user ">
  <label for="username_or_email" tabindex="-1">Username or email</label>
  <input aria-required="true" autocapitalize="off" autocorrect="off" autofocus="autofocus" class="text" id="username_or_email"  name="session[username_or_email]" type="text" value="">
</div>
<div class="row password ">
  <label for="password" tabindex="-1">Password</label>
  <input aria-required="true" class="password text"  id="password" name="session[password]" type="password" value="">
</div>
+4

All Articles