2

I'm trying to use Selenium in an Ubuntu 18.04(amd64) LXC container.
Selenium version 3.14.1, firefox version 62.0.3, Python 2.7

I installed geckodriver-v0.22.0-linux64.tar.gz from https://github.com/mozilla/geckodriver/releases into /usr/local/bin (which is in my path)

When I try to import driver I get the following error:

>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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 253, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 324, 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: invalid argument: can't kill an exited process

I saw this similar post, and the issue ended up being a version compatibility issue between Selenium, Firefox, and GeckoDriver, but I don't think that is the case for me.

I've googled and googled with no luck. Took a look at a couple of github posts as well, still no luck. I'm hoping someone here can give me some ideas.

Maybe there is an issue with doing this in a container. However, I did try this on a normal Ubuntu system (not in a container) and got the exact same issue.

BenB
  • 41
  • 5
  • It may be a silly question but how did you install it? Did you uncompress the tar.gz and also gave execute permissions to the binary? – Santiago Bruno Oct 17 '18 at 23:28
  • @SantiagoBruno I downloaded it from the website, un-tared it and copied it to my path. It's in an lxc container, so everything is run as root and has root permissions, and the binary has execute permissions for all users. Permissions should be fine. – BenB Oct 18 '18 at 01:42
  • I just tried a quick test program on a Linux laptop I have sitting around. I did all the same steps and it worked. Doing that test I realized that it actually launches the browser. I wonder if it has to do with running it in lxc where there is no display. The server I was running this on that had the same issue might actually be a server version of Ubuntu (missing the display manager), but I'm not 100% sure. – BenB Oct 18 '18 at 02:00
  • You should always _execute your @Test as a non-root user._ – undetected Selenium Oct 18 '18 at 08:02
  • @DebanjanB as mentioned, this is running in a container. The only user is root because I have not set-up other users as there is no reason to do so. The advice to run as non-root in this context is irrelevant. – BenB Oct 18 '18 at 16:05
  • @DebanjanB I also explained in my post why the other answer does not address my situation. Why did you mark it as a duplicate? – BenB Oct 18 '18 at 16:07

1 Answers1

2

Just in case someone stumbles on this and had a similar issue, the root of my issue is that all of my original attempts to use the webdriver took place from lxc exec <container> bash, or from an ssh session without using ssh x11 forwarding. In both scenarios the python webdriver failed because it could not actually launch the browser. I've run it in a few different environments now, all using x11 forwarding, and it's working.

BenB
  • 41
  • 5