J.C
J.C

Reputation: 105

Selenium Python Error

I am trying to create a small test program that is able to login into gmail. So far the program opens up the website on chrome but then fails to actually type anything into the "Enter Email" form box. Also I am receiving an error within the shell which may provide insight into my question.

Driver Version: 2.40 Chrome Version: 67.0.3396.99

Below is the code:

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

driver= webdriver.Chrome('C:\chromedriver_win32\chromedriver.exe')
driver.get("http://mail.google.com")
emailid=driver.find_element_by_name("identifier")
emailid.send_keys("samplekeys")

Below is the error:

Traceback (most recent call last):
  File "C:\gmail.py", line 7, in <module>
    driver.get("http://mail.google.com")
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 332, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: missing or invalid 'entry.level'
  (Session info: chrome=67.0.3396.99)
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.17134 x86_64)

Any help would be greatly appreciated!

Upvotes: 2

Views: 598

Answers (2)

cruisepandey
cruisepandey

Reputation: 29362

try this :

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.common.action_chains import ActionChains

browser = webdriver.Chrome(executable_path = r'C:/chromedriver_win32/chromedriver.exe')
browser.get("http://mail.google.com")  

wait = WebDriverWait(browser, 10)

user_name = wait.until(EC.element_to_be_clickable((By.ID, 'identifierId')))
user_name.click()
user_name.send_keys("samplekeys")

Upvotes: 1

Druta Ruslan
Druta Ruslan

Reputation: 7402

You need to download the chromedriver, and put the path to your webdriver.Chrome(), for example my chromedriver are in /usr/local/bin/chromdriver

driver = webdriver.Chrome('/usr/local/bin/chromedriver')

or for widndows

driver = webdriver.Chrome(executable_path = r'C:\chromedriver_win32\chromedriver.exe')

Upvotes: 0

Related Questions