0

I have written a basic script which tries to open a website with Selenium(webdriver).

Here is my script:

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

driver = webdriver.Firefox()
driver.get("https://google.com")

driver.quit()

When I launch the above script the Firefox browser pops-up, however it remains blank and it does not navigate to the mentioned website(in this case Google)? I do get an error on terminal screen:

Traceback (most recent call last): File "test.py", line 10, in driver = webdriver.Firefox() File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 158, in init keep_alive=True) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in init self.start_session(desired_capabilities, browser_profile) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: connection refused

Here is the geckodriver log file contents:

1513507080726 geckodriver INFO geckodriver 0.19.1 1513507080735 geckodriver INFO Listening on 127.0.0.1:47815 1513507081261 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.IaZFxa8B0Ir8" 1513507085202 Marionette ERROR Error on starting server: [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]" nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)" location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95" data: no] [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]" nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)" location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95" data: no] MarionetteServer.prototype.start@chrome://marionette/content/server.js:95:19 MarionetteComponent.prototype.init@resource://gre/components/marionette.js:217:5 MarionetteComponent.prototype.handle@resource://gre/components/marionette.js:112:5

I have no idea what is going on here, I can't seem to figure out how to fix this error? Do you guys have any idea, how this error can be fixed and what is causing this?

2 Answers 2

0

As you are using geckodriver 0.19.1 use the latest Selenium v3.8.1 along with latest Firefox Quantum Web Browser.

Finally, when you initialize the webdriver, instead of driver = webdriver.Firefox() try with :

driver = webdriver.Firefox(executable_path="/path/to/geckodriver")
Sign up to request clarification or add additional context in comments.

2 Comments

Hmmmm... I thougt I had downloaded the latest Selenium version available? I did a pip3 install selenium? Alright, I will check. Thanks.
Seems like I have the latest version for Selenium(ver. 3.8.0), I can't get the version 3.8.1 through pip? Anyway I have also tried to write the executable path, but unfortunately I get the same error :/
0

Browser and its selenium driver must be matched in version.

Refer to geckodriver release page to get the right release of driver you want. Chrome webdriver is also a good choice.

The exception selenium.common.exceptions.WebDriverException: Message: connection refused is usually caused by driver mismatch with the browser.

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.