2

I have Ubuntu Server 19.04 64bit. I use the following packages:

  • nodejs v10.16.0
  • Mozilla Firefox 68.0.1

I installed selenium-webdriver ^4.0.0-alpha.4 in my node.js project.

Also I installed geckodriver 0.24.0 with the following algorithm:

sudo wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
tar -xvzf geckodriver-v0.24.0-linux64.tar.gz
chmod +x geckodriver
sudo mv geckodriver /usr/local/bin/

My project has index.js with following code:

const {Builder, By, Key, util} = require("selenium-webdriver");
const firefox = require('selenium-webdriver/firefox');
async function example() {
    let options = await new firefox.Options()
        .headless();
    let driver = await new Builder().forBrowser("firefox").setFirefoxOptions(options).build();
    await driver.get("https://mobile.facebook.com");  
    await driver.close();
}
example();

When I start my script with command sudo node index.js I get following error:

(node:1303) UnhandledPromiseRejectionWarning: WebDriverError: invalid argument: can't kill an exited process
    at Object.throwDecodedError (/var/nodejs/sites/test/node_modules/selenium-webdriver/lib/error.js:550:15)
    at parseHttpResponse (/var/nodejs/sites/test/node_modules/selenium-webdriver/lib/http.js:560:13)
    at Executor.execute (/var/nodejs/sites/test/node_modules/selenium-webdriver/lib/http.js:486:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:1303) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1303) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Error: invalid argument: can't kill an exited process, and I dont't know, how fix this... If you need more information about my situation, please, ask me, I will try to answer.

UPD: I tried last versions of geckodriver and loock at that I get:

0.24.0: WebDriverError: invalid argument: can't kill an exited process

0.23.0: WebDriverError: invalid argument: can't kill an exited process

0.22.0: WebDriverError: invalid argument: can't kill an exited process

0.21.0: WebDriverError: Process unexpectedly closed with status 1

0.20.1: WebDriverError: Process unexpectedly closed with status 1

0.20.0: WebDriverError: Process unexpectedly closed with status 1

...

GeneralTao
  • 51
  • 6

2 Answers2

2

You need to update your Firefox browser, it can happen because of mismatch between GeckoDriver and the Firefox Browser.

If that also don't work then use below version of gecko driver, try with 2nd and 3rd last updated version of gecko driver.

Not recommanded, still it is possible that you need to downgrade your browser and try it latest or try with 2nd and 3rd last updated version of gecko driver. you should try to update the same with latest version afterwards when binary are available for latest firefox version

It also one of the probability that your geckodriver is not quit and so it is still running behind which suppress new session to open, you can use below article to kill your geckodriver process

https://www.tecmint.com/find-and-kill-running-processes-pid-in-linux/

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
  • Thanks, it was really mismatch between GeckoDriver and the Firefox Browser. – GeneralTao Jul 26 '19 at 11:01
  • That’s great that it works for you .. can you please accept answer by click on right sign ... it will help thanks – Shubham Jain Jul 27 '19 at 12:19
  • I accepted your answer, but, please edit your answer: `you need update Firefox` to `you need downgrade Firefox` or something like that. I changed my farefox's version to more old - 57, and this was solution of my problem. – GeneralTao Jul 28 '19 at 12:42
  • Thanks @GeneralTao .. I have updated the answer and upvoted your answer and question as well .. cheers – Shubham Jain Jul 29 '19 at 08:53
1

So, after long testing of different versions of geckodriver and farefox I solved my problem!

I just tried to make downgrade of farefox to v57.0, but I dont't tried with newer versions. I steal use geckodriver 0.24.0.

More information about downgrade here https://askubuntu.com/questions/661186/how-to-install-previous-firefox-version

GeneralTao
  • 51
  • 6