1

My code is:

from selenium import webdriver

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException

baseurl = "https://www.google.ca/?gfe_rd=cr&ei=J5ooWerXOsf_8AebtKKICw&gws_rd=ssl"
search = "panda"

xpaths = { 'searchbox' : ".//*[@id='lst-ib']",
   'submit' : ".//*[@id='tsf']/div[2]/div[3]/center/input[1]",
   'img' : ".//*[@id='gbw']/div/div/div[1]/div[2]/a"
 }

driver = webdriver.Firefox()
driver.get(baseurl)

driver.find_element_by_xpath(xpaths['searchbox']).clear()
driver.find_element_by_xpath(xpaths['searchbox']).send_keys(search)
driver.find_element_by_xpath(xpaths['submit']).click()
#driver.find_element_by_xpath(xpaths['img']).click()

Firefox opens, but nothing at all happens, and written in the terminal is the following:

Traceback (most recent call last):
File "sg1.py", line 21, in <module>
driver.find_element_by_xpath(xpaths['searchbox']).send_keys(search)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 347, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 494, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Expected [object Undefined] undefined to be a string

Things to note: Firefox is up to date.

When Firefox opens it opens a plain version and not the version that usually opens with add-ons such as adblocker, firebug, etc.

When i ran just the click on 'img' bit that is commented out it did what it was supposed too.

10
  • update your geckodriver version to 0.16 also selenium to 3.4.0 Commented May 28, 2017 at 6:39
  • Ok I will do both of those things as soon as I get back home. If I have a concern or problem may I ask you for a point in the right direction if it needed? Commented May 28, 2017 at 6:44
  • yes of course... Commented May 28, 2017 at 6:45
  • Ok, I'm back home. It's been a while since I had to install geckodriver and I remember I had to do a lot of reading on putting it in the correct place and such. Do you know an easy was I could just update it to that version from terminal. And should I update selenium or geckodriver first? Commented May 28, 2017 at 8:47
  • No such restrictions are there Commented May 28, 2017 at 9:00

1 Answer 1

1

This issue is common with geckodriver v.015; In order to resolve this update your geckodriver version to 0.16 also selenium to 3.4.0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.