9

Trying to run multiple processes concurrently on the same machine, which use Selenium. What would happen is something like this:

python my_selenium_process1.py &
python my_selenium_process2.py &
python my_selenium_process3.py &

As far as I have been able to test, this results in Selenium opening the Firefox instances in sequence, which is not the desired behavior.

Additional note: According to this question on superuser about multiple Firefox instances, the way to do this would be to use the --no-remote start up flag for Firefox. This seems like a good way to go, but I'm not sure if there is a simpler way to do it or if this is even what I'm looking for.

Edit: The purpose, more than speeding up a particular test case, is to allow multiple Selenium processes to run concurrently.

Thanks very much! Any suggestion will be appreciated!

Community
  • 1
  • 1
Juan Carlos Coto
  • 11,900
  • 22
  • 62
  • 102
  • 1
    Assuming you want to cut down the test duration, have you looked at http://code.google.com/p/selenium/wiki/Grid2? – Thomas Fenzl May 14 '13 at 19:41
  • Thanks for your observation, but this is not necessarily true. I have edited the question to clarify the use case a little further. Basically, the test can be different, but we need them to run simultaneously. – Juan Carlos Coto May 14 '13 at 19:58
  • FYI, nose can run tests [in parallel](http://nose.readthedocs.org/en/latest/doc_tests/test_multiprocess/multiprocess.html). – alecxe May 14 '13 at 20:58
  • Cool.... Can you use something like Selenium's `WebDriver`s with `nose`? – Juan Carlos Coto May 14 '13 at 22:05
  • 1
    Learn about the `thread` module , if you want to run different 'anything' at the same time. Ive used it in the past, with selenium and its been fine. – TehTris May 17 '13 at 16:36
  • @TehTris can you confirm that running different threads will prevent selenium from effectively serializing access to the webpages loaded in each process? I have actually run each program in a separate process and it seems to serialize Firefox access. – Juan Carlos Coto May 17 '13 at 16:46
  • Not quite sure i understand what you mean. But, each selenium thread has nothing to do with the other ones, and the threads run simultaneously. It is completely different than double clicking on firefox, and then double clicking on firefox again and doing manual things, they will literally be going at the same time. so more parallel than serial if i follow correctly. – TehTris May 17 '13 at 16:54

3 Answers3

3
sudo easy_install -U python-wd-parallel

then

check the usage here

https://github.com/OniOni/python-parallel-wd

Gus
  • 573
  • 1
  • 5
  • 18
2

Have you considered implementing a selenium grid?

Selenium Grid will help you scale by running tests in parallel. Just setup a hub and node with the following commands:

For the hub

java -jar selenium-server-standalone-2.30.0.jar -role hub

and for the node

java -jar selenium-server-standalone-2.30.0.jar -role node  -hub http://localhost:4444/grid/register
Amey
  • 8,470
  • 9
  • 44
  • 63
  • It is not very clear how this relates to the question. The motivation is to run several Firefox browsers, not parallel tests. – Juan Carlos Coto Aug 27 '13 at 15:47
  • 1
    Selenium Grid is not meant only for parallel tests. Selenium grid provides a hub which acts as a load balancer. So when you trigger the same test script or different (but where the selenium server port number is hardcoded - 4444 or 5555) the selenium grid hub will allocate the tests to various other selenium-server-ports that have been associated with the Selenium Grid setup. I would recommend taking a look at the link provided in the answer to get a better idea. – Amey Aug 27 '13 at 16:04
1

You can user Selenium Grd 2

  • it allows to scale by distributing tests on several machines ( parallel execution ) Check Out here
Community
  • 1
  • 1
Ravi Pal
  • 395
  • 1
  • 7
  • 22