相关文章推荐
打篮球的手电筒  ·  JCIM | ...·  1 月前    · 
宽容的大熊猫  ·  Mounting a Single ...·  11 月前    · 
道上混的紫菜汤  ·  IApplicationGateway ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am very new to Selenium and all of the sudden for no reason an error is stopping me from running ANY Selenium tests.

This is the error I am getting when I run my Python script:

2018-05-14 12:07:52,766 [INFO ]  Getting Selenium setup here.
Traceback (most recent call last):
  File "test.py", line 308, in <module>
    webcrawler.crawl()
  File "test.py", line 177, in crawl
    self.web_crawl.setup()
  File "/test/src/webcrawlers/utils/webcrawl_lib.py", line 83, in setup
    self.browser = webdriver.Firefox(firefox_profile=profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 162, in __init__
    keep_alive=True)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, 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: Process unexpectedly closed with status 1

Now I can usually debug these issues. However, the geckodriver.log is not giving me much to work with:

1526299672891   geckodriver     INFO    geckodriver 0.20.1
1526299672895   geckodriver     INFO    Listening on 127.0.0.1:48641
1526299673899   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.YNIc2l05QiIr"
Running Firefox as root in a regular user's session is not supported.  ($HOME is /home/test which is owned by test.)

Environment:

  • Geckodriver: 0.20.1
  • Selenium: 3.12.0
  • Python: 2.7. And I tried using 3 as well
  • Firefox: 60.0
  • I even tried switching out to using Chrome, and the setup would just hang and give a unique error as well.

    A side note is that this is on Amazon AWS, and I am not the administrator on the account. Maybe something was changed on that end.

    Are you running as root, as the error implies? Also, when you say "this is on AWS", does that mean the selenium code is running on AWS, or that you're running selenium locally but talking to a server on AWS? – Bryan Oakley May 14, 2018 at 12:33 It seems like the simple solution is to not run as root. Have you tried that? There's almost never a good reason to run tests as root. – Bryan Oakley May 14, 2018 at 13:00 attempted and I got this error : raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: connection refused – user2402107 May 14, 2018 at 13:34

    I had the same problem with geckodriver 0.21.1, Selenium 3.12.0, and Python 3.5.2. It worked for me on Ubuntu 17.04 to remove Firefox and (firefox-dev) with sudo apt-get purge firefox, firefox-dev and then I install Firefox version 50.0 manually with:

    wget http://ftp.mozilla.org/pub/firefox/releases/50.0/linux-$(uname -m)/en-US/firefox-50.0.tar.bz2
    tar -xjf firefox-50.0.tar.bz2
    sudo mv firefox /opt/
    sudo mv /usr/bin/firefox /usr/bin/firefox_old
    sudo ln -s /opt/firefox/firefox /usr/bin/firefox
    

    After those steps it also worked with root.

    for geckodriver 0.19 and higher its recommended Firefox 55.0 (and greater) Selenium 3.5 (and greater) – user2402107 May 14, 2018 at 20:07

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.