Why can't run geckodriver in selenium? - python-3.x

Download chromedriver and extract it.
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/home/debian/Downloads/chromedriver')
It works fine.
Now to test geckodriver for firefox,my firefox version is 78.0.2 (64-bit),the latest version,i have downloaded the geckodriver-v0.26.0-linux64.tar.gz and extract it.
from selenium import webdriver
driver = webdriver.Firefox(executable_path='/home/debian/Downloads/geckodriver')
It encounter some issues:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/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
How to fix it?

first check if selenium are downloaded with no error and make sure that the webdriver are downloaded in the path in this code driver = webdriver.Firefox(executable_path='/home/debian/Downloads/geckodriver')
that's should fix your problem

Related

selenium.common.exceptions.WebDriverException: Message:

I am running following simple python3 script on Windows11:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
options = webdriver.ChromeOptions()
options.binary_location = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
service = Service(executable_path='C:\\ProgramFiles\\Google\\Chrome\\Application\\chromedriver.exe')
webC = webdriver.Chrome(options=options, service=service)
I am getting the flowing error:
Traceback (most recent call last):
File "E:/NNs/CrawlerStarter/selenium_test.py", line 8, in <module>
webC = webdriver.Chrome(options=options, service=service)
File "D:\Anaconda\envs\crawler\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "D:\Anaconda\envs\crawler\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 92, in __init__
super().__init__(
File "D:\Anaconda\envs\crawler\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 276, in __init__
self.start_session(capabilities, browser_profile)
File "D:\Anaconda\envs\crawler\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 369, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\Anaconda\envs\crawler\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 434, in execute
self.error_handler.check_response(response)
File "D:\Anaconda\envs\crawler\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 207, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:
Process finished with exit code 1
There is not error message to tell what's going wrong, and I have tried related solutions that could found in Google, such as setting Path in System Environment. But it's still occurred same exception. Also, I had the same problem when I switched to Firefox
Here are my versions:
python: 3.8.13
selenium: 4.4.0
google chrome: 104.0.5112.81
chromedriver: 104.0.5112.79
Thank you for answering my question!

"Unable to find a matching set of capabilities" using selenium/geckodriver for Firefox on Windows10

Versions:
geckodriver 0.26.0 (in PATH environment variable)
selenium 3.141.0
Firefox 75.0
python 3.8.2
Windows 10
When I try:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://seleniumhq.org/')
I get this:
Traceback (most recent call last):
File "C:\Users\Me\Desktop\python\FFtests.py", line 3, in <module>
driver = webdriver.Firefox()
File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 170, in __init__
RemoteWebDriver.__init__(
File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-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
When I try:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False
driver = webdriver.Firefox(capabilities = cap)
driver.get('https://seleniumhq.org/')
I get this:
Traceback (most recent call last):
File "C:\Users\me\Desktop\python\FFtests.py", line 6, in <module>
driver = webdriver.Firefox(capabilities = cap)
File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 190, in __init__
executor = ExtensionConnection("127.0.0.1", self.profile,
File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 73, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 103, in _wait_until_connectable
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
IEDriver works fine for IE
I have Windows Visual Studio installed as https://github.com/mozilla/geckodriver/releases indicates I should.
What can I do to make this work?
This is likely an issue with FireFox version. Try updating Firefox and Selenium.
Update Firefox
Update Selenium
Reinstall/update Geckodriver
See here for more solutions.

Windows10 ubuntu bash: chromedriver can not initiate Chrome?

I am trying to use chromeriver to fetch some url. But It is not working.
This is my code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
#from langdetect import detect, DetectorFactory
chrome_options = Options()
# chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
# chrome_options.add_argument('--remote-debugging-port=9222')
driver = webdriver.Chrome(
chrome_options=chrome_options)
which gives me this error:
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
It apparently can't start the Chrome.
If I uncomment this line in the code:
chrome_options.add_argument('--headless')
It stops working and I have to break it with ctrl + C
which shows this traceback:
Traceback (most recent call last):
File "/home/payman/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 379, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "crawler.py", line 14, in <module>
chrome_options=chrome_options)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/home/payman/.local/lib/python3.6/site-packages/urllib3/request.py", line 72, in request
**urlopen_kw)
File "/home/payman/.local/lib/python3.6/site-packages/urllib3/request.py", line 150, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/home/payman/.local/lib/python3.6/site-packages/urllib3/poolmanager.py", line 326, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/home/payman/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/home/payman/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt
My chromedriver executable is stored in the this directory \usr
and so in the .bashrc I have added:
export PATH="/usr:$PATH"
I have followed the installations on this page:
How to Setup Selenium with ChromeDriver on Ubuntu 18.04 & 16.04

Trying to connect to tor with python3

I have been trying to connect to tor with python on Mac. If it helps, I have python3 and Mac Mojave. My code is:
import stem.process
from stem import Signal
from stem.control import Controller
from splinter import Browser
proxyIP = "127.0.0.1"
proxyPort = 9150
proxy_settings = {"network.proxy.type":1,
"network.proxy.ssl": proxyIP,
"network.proxy.ssl_port": proxyPort,
"network.proxy.socks": proxyIP,
"network.proxy.socks_port": proxyPort,
"network.proxy.socks_remote_dns": True,
"network.proxy.ftp": proxyIP,
"network.proxy.ftp_port": proxyPort
}
browser = Browser('firefox', profile_preferences=proxy_settings)
browser.visit("http://www.icanhazip.com")
However, whenever I run it, an error occurs:
Traceback (most recent call last):
File "test.py", line 27, in <module>
browser = Browser('firefox', profile_preferences=proxy_settings)
File "/usr/local/lib/python3.6/site-packages/splinter/browser.py", line 64, in Browser
return driver(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/splinter/driver/webdriver/firefox.py", line 78, in __init__
**kwargs
File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.6/site-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
Any help would be appreciated. Regards, Tyler
I don't know your selenium version and geckodriver version,so what i can answer is upgrade them.
pip install -U selenium
download latest version geckodriver from here

Cannot load jupyter-notebook from terminal in Ubuntu 14.04

After installing the latest version of Anaconda, and following post-installation steps, I am not able to load jupyter notebook on my system, Ubuntu 14.04.
I get the following error message:
Traceback (most recent call last):
File "./bin/jupyter-notebook", line 6, in <module>
sys.exit(notebook.notebookapp.main())
File "/home/carlos/anaconda3/lib/python3.5/site-packages/jupyter_core /application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/home/carlos/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
app.initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "/home/carlos/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
return method(app, *args, **kwargs)
File "/home/carlos/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 1023, in initialize
self.init_webapp()
File "/home/carlos/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 882, in init_webapp
xheaders=self.trust_xheaders)
File "/home/carlos/anaconda3/lib/python3.5/site-packages/tornado/util.py", line 221, in __new__
instance.initialize(*args, **init_kwargs)
File "/home/carlos/anaconda3/lib/python3.5/site-packages/tornado/httpserver.py", line 155, in initialize
read_chunk_size=chunk_size)
File "/home/carlos/anaconda3/lib/python3.5/site-packages/tornado/tcpserver.py", line 112, in __init__
self.ssl_options['certfile'])
ValueError: certfile "jupnb.pem" does not exist
The certfile actually exists, in the directory ~/.jupyter/
I haven't been lucky googling the solution. Any comments?
Thanks!
Carlos
edit ~/.jupyter/jupyter_notebook_config.py and check the correct paths,
e.g. for ~/.jupyter/jupnb.key and ~/.jupyter/jupnb.pem:
import os
c.NotebookApp.keyfile = os.path.expanduser('~') + '/.jupyter/jupnb.key'
c.NotebookApp.certfile = os.path.expanduser('~') + '/.jupyter/jupnb.pem'

Resources