1
votes

sorry, I read several threads but couldn't quite find a solution. So, what I am trying to do is using Selenium with firefox on WSL. The code looks something like this:

    def getHTML_(self):
        '''
            getting HTML with beautifulsoup and selenium
        '''
        options = Options()
        options.set_headless(headless=True)
        options.log.level = "trace"
        browser = webdriver.Firefox(firefox_options=options)

What I get is the following (known) error:

selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

The .log says:

1603805101772 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilehybl9w" Error: no DISPLAY environment variable specified 1603805357626 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile2x1kmq" *** You are running in headless mode. Exiting due to channel error.

And then follows a loooong list with

[Parent][MessageChannel] Error:

... that finally results in the killing error.

I've tried different combinations of firefox versions, geckodriver, selenium. Among them the latest versions Selenium 3.14, geckodriver 0.27, firefox 82. Nothing works. Am I getting this right that the webdriver is still trying to start firefox without headless mode first?! But why? I am passing the argument that it should be run in headless mode, am I not?

Thanks for your help!

1

1 Answers

0
votes

The error is pointing towards version mismatch( between gecko/selenium etc. However, your versions are correct) or a problem with the website itself. So, the URL would help. This error is generated by Firefox invalid argument: can't kill an exited process in case of an issue with the application . It is not a headless issue. You can try setting the firefox binary manually like so

binary = FirefoxBinary('F:\FirefoxPortable\Firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)