Steph_Xavier
Steph_Xavier

Reputation: 11

Firefox fails to open url when using webdriver python API

I am new to python and trying to build a selenium code to open a website via firefox. I am using a debian stretch machine for the tests. The versions of the tools are given below :

geckodriver 0.24.0 ( 2019-01-28) , Python 2.7.13 , Mozilla Firefox 52.7.3 , selenium (3.141.0)

I see that the firefox window opens( even though in headless). But it doesnt proceed further with opening the website. The firefox instance waits for sometime after opening and then stops, the script gives error like

WebHandle.open_application("Firefox" , "http://www.google.com") File "/home/yyyyy/yyyyy/yyyyy/yyyyy/script.py", line 49, in open_application driver = webdriver.Firefox(firefox_options = options, executable_path='/usr/local/bin/geckodriver') 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.WebDriverException: Message: connection refused

Code :

from selenium import webdriver
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options as FirefoxOptions

        options = FirefoxOptions()
        options.add_argument("--headless")
        print (" * Opening firefox session")
        driver = webdriver.Firefox(firefox_options = options, executable_path='/usr/local/bin/geckodriver')
        driver.get("https://www.google.com")
        driver.maximize_window()
        print(driver.title)

While looking into the geckodriver.log , I see the following errors

1624193615192 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "--headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.Wwi0327B9dAL" 1624193616996 Marionette INFO Listening on port 2828

[Child 28357] ###!!! ABORT: Aborting on channel error.: file /build/firefox-esr-52.7.3esr/ipc/glue/MessageChannel.cpp, line 2152 [Child 28357] ###!!! ABORT: Aborting on channel error.: file /build/firefox-esr-52.7.3esr/ipc/glue/MessageChannel.cpp, line 2152

###!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv ###!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv

Thanks already for any help in fixing the issue

Upvotes: 1

Views: 663

Answers (1)

Libin Thomas
Libin Thomas

Reputation: 979

Try placing the geckodriver.exe file in a separate folder & drive and updating the path in executable_path.
eg:

driver = webdriver.Firefox(firefox_options = options, executable_path=r"D:/Python/drivers/geckodriver.exe")

Upvotes: 0

Related Questions