Selenium Grid, running multiple browser instances in parallel - selenium

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.

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 Node is repeatedly registering with the hub (Selenium 3.3)

I run this command on a virtual machine to register a node with my Selenium Grid hub:
java -Dwebdriver.ie.driver=C:\IEDriverServer.exe -Dwebdriver.chrome.driver=C:\chromedriver.exe -Dwebdriver.gecko.driver=C:\geckodriver0-15-0.exe -jar selenium-server-standalone-3.3.0.jar -role node -port 5555 -hub http://10.201.1.201:4444/grid/register -browser "browserName=internet explorer, version=10, platform=WINDOWS, maxInstances=5" -browser "browserName=chrome,maxInstances=5,platform=WINDOWS" -browser "browserName=firefox,maxInstances=5,platform=WINDOWS"
As a result, the node seems to connect correctly, but every minute or so I see
"Registering the node to the hub: [hub ip]
The node is registered to the hub and ready to use."
This doesn't seem to cause any errors with my tests, but I'm curious why it is repeatedly trying to register. I believe this started when I upgraded Selenium Server Standalone to 3.3.
I'm also noting that from my hub, I see that it keeps "marking the node as down because it can't be reached for 2 tries". Then it immediately registers that node again, and then it's down again, repeated forever.
There is a bug that should be fixed in version 3.3.1. It seemed to produce the same problem you're seeing. If it still doesn't work I'd recommend commenting on the github issues.

Selenium Grid Support - launch multiple browser windows from same machine

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.

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)

Selenium WebDriver and Grid 2

I try to run Grid2, but I don't understant basic thing.
I have the Hub, and I run on the hub machine the next command:
java -jar selenium-server-standalone-2.14.0.jar -role hub
I have a node, and I run on it the next command:
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://localhost:4444/grid/register
Now, I want to run a test in Java that would execute only on the node (and not on the hub). But the code of the test is on the Hub machine. How can I make it happen?
If you're running the hub and node on the same machine then yes, when you run your tests they will start on the node where your hub is located. In order to get around this you're going to need at least 2 machines, 1 to run your hub and 1 to run your node.
Start your hub on machine A then have your node register to the hub, when you start your tests on the hub machine it will automatically select an available node and run the tests.
It doesn't matter where your code lies. Your code communicates with the hub and tells it which node to execute the case on based on the desiredcapabilities object.
In your case as well, the case is running on the node only. Hub just does the task of distributing it to appropriate node. Its just that the node is on the same machine as the hub, so you do not see a difference.