I'm using:
- Debian version 9.6
- Python 2.7
- Selenium 3.141.0
- Firefox 60.3.0
I'm trying to learn how to use Selenium with Python but I have not been able to do anything yet. It always gives some error, I corrected as I found the solutions but in the latter I can not.
Code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://stackoverflow.com/")
body = driver.find_element_by_tag_name("body")
body.send_keys(Keys.CONTROL + 't')
driver.close()
Error:
root@debian:/home/yan/prog/python# python testselenium.py Traceback (most recent call last): File "testselenium.py", line 4, in driver = webdriver.Firefox() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 164, in init self.service.start() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 83, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
root@debian:/home/yan/prog/python# python testselenium.py Traceback (most recent call last): File "testselenium.py", line 4, in driver = webdriver.Firefox() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 164, in init self.service.start() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 83, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
root@debian:/home/yan/prog/python# export PATH=$PATH:/home/yan/Downloads/geckodriver-v0.23.0-linux64/ root@debian:/home/yan/prog/python# python testselenium.py Traceback (most recent call last): File "testselenium.py", line 4, in driver = webdriver.Firefox() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in init keep_alive=True) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities
root@debian:/home/yan/prog/python# export PATH=$PATH:/home/yan/Downloads