Running Selenium::Webdriver::Firefox Inside Xvfb from Ruby as Non-Root User

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

  • 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.

Error running selenium ruby script through xvfb-run

I figured this out. Misunderstanding the directions here. Installed google-chrome in /usr/bin and it worked.

Configuration of selenium webdriver with xorg-x11-server-Xvfb

Firstly, do not integrate selenium scripts with JMeter for load testing! It's not a good approach to follow due to the obvious consequences that you have mentioned in your post. I followed a similar apporach in the beginning when I was new to JMeter and selenium but suffered a great deal when it came to running load tests that spawned too many browser instances which killed the OS.

You can go for HtmlUnitDriver or any headless browser testing tools out there with JMeter, but still, they will be running the browser internally in the memory. Moreover if your application is heavily using Javascript, it won't help.

So I would suggest that you record a browsing session with JMeter Proxy and modify the script (set of requests) according to your needs and play those requests alone, with number of threads.

From a higher level, you should be doing this:

  1. Add a JMeter test plan, listeners, thread group and setup JMeter proxy and record a browsing session where you enter something into the autocomplete textbox and you get certain results.
  2. Stop your proxy and take a look at all the requests that come under your thread group.

  3. As far as I know, when it comes to autocomplete plugins, multiple
    requests are sent everytime you enter a letter into the textbox. For
    example, for the word 'stackoverflow':

    Request1: q=s
    Request2: q=st
    Request3: q=sta
    and so on

    Here you can simulate this effect by including words such that all
    words have the same length which in turn will let you have same
    number of requests to be sent to the server.

  4. So in your test plan, you will pass one word per Jmeter thread. You
    can pass the words to a request, from a csv file by using jmeter
    parametrization.

This will be a much memory efficient way of load testing instead of using selenium with JMeter. I had asked a similar question. You can check out the responses.

multiple headless firefox instances using watir-webdriver within rails application

I found out that I can use the CGI module to do my work. Since I didnt need a rails application, I used ruby CGI to call the ruby script and pass parameters through URL. I can also launch multiple instances in a non-blocking fashion using this approach. I had to re-write my controller as a stand alone ruby program in order to do this.



Related Topics



Leave a reply



Submit