Running Selenium::WebDriver::Firefox inside Xvfb from ruby as NON-root user

后端 未结 3 1287
失恋的感觉
失恋的感觉 2021-01-05 11:41

I\'m trying to do some headless testing using a ruby script. Essentially I\'m executing Xvfb on display :1, and then firing up Watir::Browser.new(:firefox) usi

相关标签:
3条回答
  • 2021-01-05 12:24
    • SOLVED - EDIT * - sorry I couldn't ANSWER the question, but apparently my account is too new to do that just yet.

    Solved! Amazing how things like this tend to solve themselves AFTER you've asked the question...

    For those wanting to know why, there's a few things I needed to do...

    1) Make sure the user in question has a working home directory (www-data didn't by default... its home dir was owned by root)

    2) Start Xvfb from command line, and then start firefox from the command line (NOT from within the script) - this will populate the users home folder with the usual .dbus, .gconf etc folders

    3) If you get a massive delay and then an error message along the lines of "an error occurred while loading or saving configuration information for firefox-bin", delete the .dbus folder in the users home directory

    4) Try #2 again - if you had a config error before, it should now be gone.

    5) Try running the script again.

    This worked like a charm for me, so if you're having similar issues running Xvfb and watir-webdriver from within a web app, give it a try.

    Thanks to all for contributing to what is hands-down the BEST Q&A site on the web... this place has saved my butt more times than I care to mention.

    Note: the user originally entered this amended to their question, because they could not figure out how to post it as an answer. That was later edited out of the question by some well meaning person but never added as an answer.

    0 讨论(0)
  • 2021-01-05 12:28

    You should also take a look at Ruby wrapper for Xvfb http://rubygems.org/gems/headless

    0 讨论(0)
  • 2021-01-05 12:37

    Hi don't know if this link could be a help for you. This helped me a lot. I needed to run watir-webdriver automatically at startup/reboot - it worked for me (read the comments as well).

    0 讨论(0)
提交回复
热议问题