Selenium Grid Support - launch multiple browser windows from same machine - selenium

We know that Selenium Grid is supporting parallel testing from different machines.
My Objective is to launch multiple browser windows from same machine and launch tests from same machine parallel. Is it possible with Selenium grid? Could you guide me here, please?
Regards,
-kranti

Yes, you can do it and you can even specify how many windows you want to run at once on given computer. All is done through -browser parameter:
java -jar selenium-server-standalone-2.42.0.jar -role node -browser browserName=firefox,maxInstances=3 -hub http://localhost:4444/grid/register
The above parameter allows the node to run up to 3 instances of firefox browser at once.
Later on, the computer will open 3 different instances of Firefox and run the tests. It worked well in my setup.

Related

Safari does not support execution of automation scripts on multiple thread,

Safari does not support execution of automation scripts on multiple threads, Please let me know if there are any alternatives to run selenium tests in parallel. I am running tests in parallel on other browsers like chrome and firefox. The Framework is developed in python using pytest and I am using pytest-xdist to run the scripts in parallel. I also tried pytest-parallel but even this did not help.
Have you searched other related threads?
Example thread from about 8 months ago: here
Paraphrased quote from there:
My expectation is that you're hitting default maxSession limit of
5 browser instances.
You can double check it by opening your Selenium Grid console and
looking into node configuration:
The value can be ramped up by providing the relevant maxSession
parameter to your Selenium Grid Node startup command line like:
java -jar selenium-server-standalone-3.141.59.jar -role node -maxSession 10 -hub http://localhost:4444/grid/register
^^^^^^^^^^^^^^
References

Selenium Grid, running multiple browser instances in parallel

I'm using Selenium grid to run multiple instances of my test in parallel. I want to test if I can run a lot of browsers at the same time. My problem is that I can't have more that 5 five browsers at the same time, and I don't know why.
Here are the commands I'm using to start the hub and the node:
java -jar %seleniumPath% -port 4444 -role hub -nodeTimeout 1000
java -jar %seleniumPath% -role node -hub http://localhost:4444/grid/register -browser browserName=firefox,maxInstances=1,maxSession=1 -port 5555
NOTE: The two commands are working but what I don't understand are the maxInstances and the maxSession arguments. I set them to 1 but I can still run more than one browser and if I set them to 10 or more only 5 browsers will run at the same time.
What should I do to have more than 5 browsers running at the same time?
Generally, according to Selenium Grid2 official documentation, -maxSession is the maximum number of browsers that can run in parallel on the node while -maxInstances sets how many instances of a particular browser can run simultaneously.
Don't forget to restart the local java process responsible for node session on each remote machine to apply these settings.

What is the difference between running the selenium standalone server and hub/node setup

I started with the selnium stand alone server setup
java -jar selenium-server-standalone-2.32.0.jar
Which allowed to me successfully connect and run my tests, with multiple browsers running at a time.
What is the difference when i use the following set-up, as a hub...
java -jar selenium-server-standalone-2.42.2.jar -role hub
and an attached node...
java -jar .\selenium-server-standalone-2.42.2.jar -role node -hub http://localhost:4444/grid/register
which also seemed to work the same.
Is the hub/node set-up my best option just purely for configuration flexibility?
Hub/Node setup gives you the flexibility to run tests on different machines and different environment. Sometimes you may want to a run test in different browsers or different version of browsers ex on IE 6 to 10. In such cases you can setup multiple nodes with different versions of IE. While on single machine you cant have multiple versions of IE.
Also with Grid you can run multiple tests in parallel across different nodes. If your script doesn't demand such environments or parallel execution you can use single machine.
Hub/Node is useful if you need to run tests on a variety of operating systems/browser configurations. For instance you could have Nodes running XP, Windows 7, Windows 8.1. Each of these machines could also be running a different version of each internet browser (if you need to support IE8 on Windows XP for instance). This allows you to test around a wide variety of configurations. I've found that running tests on my local machine is generally sufficient, but it really depends on the needs of your application.
For further reading check out:
http://www.guru99.com/introduction-to-selenium-grid.html
and
https://saucelabs.com/
Hope this helps!

How to run selenium server sessions on different xvfb screens?

My problem is how to get an isolated video streams from SeleniumServer browser instances. Let me explain.
I have Selenium Server hub running at Ubuntu Server machine and the Selenium Server node running at the same server so I use the 'headless' Selenium mode using xvfb. I run the nodes like this: DISPLAY=:99 java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register
Then I wanna get video streams of the tests running there so I installed the x11server connected to the xvfb virtual display and after that I can to connect those remote server using VNC and I see my tests processing. The trouble is that all browser instances inside the node rendered at the same virtual display (#99) and when I need running several tests at the same time, I see many browser instances overlaying one by one. But I wanna record the error tests video streams so I can't do this. So I need to have probability to connect to every browser virtual display apart.
I think I can solve this problem by tuning the xvfb server somehow to force it to create isolated virtual display or screen (xvfb has multiscreen support, hasn't it?) for every client (browser instance in my case). But I have tried to do this and I have not get a result. Also I can use another virtual display (not xvfb) if it's necessary to solve this.
Please, help me to get isolated video streams from every browser instance :) Thanks a lot and sorry about my English.
With the selenium hub, you can add the browsers in separately in their own Xvfb sessions
java -jar selenium-server-standalone-2.33.0.jar -role hub&
then connect each browser separately in its own Xvfb session, DISPLAY and port
export DISPLAY=:11
Xvfb :11 -screen 0 1024x768x16 &
java -jar selenium-server-standalone-2.33.0.jar \
-role node \
-port 4441
-hub http://localhost:4444/grid/register \
-browser "browserName=firefox,version=19,maxInstances=5"&
For this kind of use, you could typically use the xvfb-run command (which can select automatically a display, but it can be configured)
Then you can create a firefox start script that would do xvfb-run firefox that you could use as the selenium firefox start command (specified as a FirefoxBinary)

Running Selenium IDE tests via Selenium Grid

I should start off by saying that I am regretfully and painfully a noob. But I'm trying to change that!! I do not know any programming languages, but have managed to "make things happen" by doing enough research to get whatever job I've ever needed done done.
Anyway, I have been creating Selenium tests using the Selenium IDE and I am having a bit of trouble getting these test to run via Selenium Grid.
I have been exporting the tests as JUnit 4 (Webdriver) files. I am running the grid on a Ubuntu headless server, and my remote controls on one Windows 7 machine running IE9 and Firefox, and a Windows Vista machine running IE8 and Chrome.
My goal is to take the tests that I've exported from Selenium IDE as JUnit 4 (Webdriver) files and run them from the grid in parallel on my two Windows machines. I have edited my hosts files on my Windows machines to recognize the Ubuntu server by the name of "seleniumgrid". For example:
On the Ubuntu server terminal 1:
ant launch-hub
Win7 terminal1:
ant -Dport=5555 -Denvironment="IE9 on Windows" -Dhost=Win7 -DhubURL=http://seleniumgrid:4444 launch-remote-control
Win7 terminal2:
ant -Dport=5555 -Denvironment="Firefox on Windows" -Dhost=Win7 -DhubURL=http://seleniumgrid:4444 launch-remote-control
Vista termina1:
ant -Dport=5555 -Denvironment="IE8 on Windows" -Dhost=WinVista -DhubURL=http://seleniumgrid:4444 launch-remote-control
Vista terminal2:
ant -Dport=5555 -Denvironment="Chrome on Windows" -Dhost=WinVista -DhubURL=http://seleniumgrid:4444 launch-remote-control
Now, from here, I'm trying to launch the JUnit4 (webdriver) file that I have exported from Selenium IDE to run this configuration. The name of the file is titled : Registration.java.
What do I have to do now to run the Registration.jar file? I can't seem to find any documentation that answers this question, which leads me to believe that I have a fundamental misunderstanding of how this all works...
Pardon if this question has been answered before. I have poor terminology when it comes to this stuff.
HUGE thanks for taking the time to read this, and even more for an answer if there is one.
-brandon
There is no need to launch hub and nodes via ant. You can run them from cmd:
java -jar selenium-server-standalone-2.21.0.jar -role hub -- will run hub
java -jar selenium-server-standalone-2.21.0.jar -role node -hub http://seleniumgrid:4444/grid/register -- will run node
Default port for node is 5555, so for the second terminal you should specify port that differs from default one, e.g. 5556:
java -jar selenium-server-standalone-2.21.0.jar -role node -port 5556 -hub http://seleniumgrid:4444/grid/register
Also you should specify browser parameters for each node, e.g.:
-browser browserName=firefox,maxInstances=5,platform=WINDOWS
In your JUnit tests you should use RemoteWebDriver with DesiredCapabilities:
DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
For parallel execution you should edit your tests additionally (sorry, don't work with jUnit, so can't help here much except of link that you can find below.)
Include JUnit class files, your class files, including your JUnit test classes, libraries your class files depend on in your classpath on Linux machine:
export CLASSPATH=$JUNIT_HOME/junit.jar:/myproject/classes:/myproject/lib/something.jar
Invoke the Junit command on Linux machine:
java org.junit.runner.JUnitCore [test class name]
Or you can use ant instead.
I will recommend to start with hub on Linux and one node with one browser on Windows without any parallelization, so you will be sure that this part works correctly. As a next step run tests for two nodes sequentially and then try to run them in parallel.
For complete tutorials read these materials: How do I run JUnit using Ant, Activating Junit tests from Command Line, Grid2 tutorial, Parallel JUnit 4 and Selenium (three parts)