I am trying to set the maximum instances and maximum sessions for Selenium Standalone Server, as there is a good chance I will need quite a few instances/browsers.
I have tried the following command:
xvfb-run java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -jar /usr/local/bin/selenium-server-standalone.jar -maxSession 100 -maxInstances 100
However I receive the following error:
Exception in thread "main" com.beust.jcommander.ParameterException:
Unknown option: -maxSession at
com.beust.jcommander.JCommander.parseValues(JCommander.java:742) at
com.beust.jcommander.JCommander.parse(JCommander.java:282) at
com.beust.jcommander.JCommander.parse(JCommander.java:265) at
com.beust.jcommander.JCommander.(JCommander.java:210) at
org.openqa.grid.selenium.GridLauncherV3$1.setConfiguration(GridLauncherV3.java:227)
at
org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:155)
at
org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:75)
Similar thing happens when I try running it only with maxInstance.
How can I set up a large/infinite amount of instances/browsers? what is the default amount? (also can't find anywhere) Thanks in advance.
According to Selenium Grid docs, maxSession and maxInstances are parameters for the node but not for the hub.
-maxSession 5 (5 is default) The maximum number of browsers that can run in parallel on the node. This is different from the maxInstance of supported browsers (Example: For a node that supports Firefox 3.6, Firefox 4.0 and Internet Explorer 8, maxSession=1 will ensure that you never have more than 1 browser running. With maxSession=2 you can have 2 Firefox tests at the same time, or 1 Internet Explorer and 1 Firefox test).
(source: https://github.com/SeleniumHQ/selenium/wiki/Grid2#optional-parameters)
So in your case, you most likely should manage a number of parallel threads by setting up one or multiple (recommended as safer, because if 1 of 100 nodes break other will still be able do the job) nodes.
run the hub with: java -jar selenium-server-standalone-.jar -role hub
run node 1: java -jar selenium-server-standalone-<version>.jar -role node -port 4001 -hub http://localhost:4444/grid/register
run node 2: java -jar selenium-server-standalone-<version>.jar -role node -port 4002 -hub http://localhost:4444/grid/register
...
run node 20: java -jar selenium-server-standalone-<version>.jar -role node -port 420 -hub http://localhost:4444/grid/register
will give you a grid with 100 browsers (as 5 is a default value for a node and you set up 20 nodes)
Note: make sure your hardware can hold up 100 browser instances, as most likely it will not and you will want to run nodes in multiple VMs.
Another note: Selenium grid has a known weakness when there are a lot of nodes. For the future if you are fine with running browsers on linux you might want to look at some docker-based solutions like selenoid (https://github.com/aerokube/selenoid)
Related
I am new to selenium grid. So can someone please explain me the difference between the maxSession and maxInstances. And also how many parallel browsers can be used in one node?
As per the documentation by default, starting a Selenium Grid Node allows for concurrent use of 11 browsers, comprising of 5 Firefox, 5 Chrome and 1 Internet Explorer browser.
The maximum number of concurrent tests is set to 5 by default. To change this configuration and other browser settings, you can pass in parameters to each -browser switch (each switch represents a node based on your parameters). If you use the -browser parameter, the default browsers will be ignored and only what you specify command line will be used.
maxInstances
maxInstances is an optional parameter which can be passed through the -browser optional parameter. To configure a Selenium Grid Node for 20 instances of Firefox version=X.Y.Z you can use the following solution:
Command:
java -Dwebdriver.gecko.driver=geckodriver.exe -jar selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.1.125:4444/grid/register -browser browserName=firefox,version=X.Y.Z,maxInstances=20,platform=WINDOWS
Grid Console Snapshot:
-maxSession
-maxSession is also an optional parameter which can be passed through the -browser optional parameter to configure the maximum number of browsers that can run in parallel on the node. This is different from the maxInstance of supported browsers (Example: For a node that supporting Firefox version A.B.C, Firefox version P.Q.R and Chrome version X.Y.Z, maxSession=1 will ensure that you never have more than 1 browser running. With maxSession=2 you can have 2 Firefox tests executing at the same time, or 1 Firefox and 1 Chrome test).
Example:
java -Dwebdriver.gecko.driver=geckodriver.exe -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.1.125:4444/grid/register -browser "browserName=firefox,version=A.B.C,maxInstances=10,platform=WINDOWS" -browser "browserName=firefox,version=P.Q.R,maxInstances=10,platform=WINDOWS" -browser "browserName=chrome,version=X.Y.Z,maxInstances=20,platform=WINDOWS" -maxSession 2
Grid Console Snapshot:
This problem is making me crazy. I'll try to explain it.
I have a Selenium grid environment with two machines (HUB & NODE). I use .bat files to start the hub and the nodes, something like the code below:
HUB:
Here I start the hub:
start java -jar C:\workspace\selenium-server-standalone-2.45.0.jar -role hub -port 4444
Here I start a .bat on the node machine that will start the node.
psexec.exe \\XXX.XXX.XX.XXX -s -e -u USER -p PASSWORD -i 2 C:\Selenium\StartNode.bat
NODE:
To register the node:
java -jar C:\selenium\selenium-server-standalone-2.45.0.jar -role node -hub http://XXX.XXX.XX.XXX:4444/grid/register
I have this from the beginning (more or less 6 moths) and was fine and simple, but now I see very weird (for me) things but only in Internet Explorer. Basically, the node starts, IE opens to correct page but nothing happens. I just have "object not found errors..." Firefox and Chrome are just fine.
But, if I start the node directly on it (NODE machine, so not from HUB via psexec), it works fine for IE as well?
Do you guys have any logical explanation? I really have no idea.
I suppose you need to provide IEDriver exe when starting the node like below.
java -jar selenium-server-standalone-2.45.0.jar -role webdriver -hub http://192.168.1.100:4444/grid/register -browser browserName="internet explorer",version=10.0,platform=WINDOWS -Dwebdriver.internetexplorer.driver=c:\Selenium\InternetExplorerDriver.exe
Try to create node using such command:
java -Dwebdriver.ie.driver=C:\selenium\IEDriverServer.exe -jar C:\selenium\selenium-server-standalone-2.45.0.jar -role node -nodeConfig C:\selenium\nodeIE1.json
I used node instead webdriver (the last one is used for backward compatibility) and latest version of IEDriverServer
It works great for me. And you may try nssm to run your hub and node as win services instead using .bat files.
Im using Selenium Grid. When I run a test against my test site, I will hit the following error.
System.InvalidOperationException : Session [(null externalkey)] not available and is not among the last 1000 terminated sessions. Active sessions are[]
The test does not fail immediately, but will navigate around the site and to different pages before failing.
My Hub set up is batch file as follows:
cd C:\Automated Tests\Selenium
java -jar selenium-server-standalone-2.43.1.jar -role hub -hubhost my.hub..ip.address -port 4445
My Node set up is batch file as follows:
cd c:\Automated Tests\Selenium\
java -jar selenium-server-standalone-2.43.1.jar -port 5560 -role node -nodehost my.node.ip.address -hub http://my.hub.ip.address:4445/grid/register -browser"browserName=firefox,version=33.0,maxInstances=2,platform=WINDOWS" -nodeTimeout 600 -maxSession 10
Theres not a lot of information on this issue, so any help would be appreciated
I was facing the same issue and I found the solution.
This might be occurring because of using old objects.
Try instantiating new objects of your web elements when you close and start new driver session.
In this case, it does not throw stale element exception but it niether finds the web element in DOM with old object reference and hence throws the error.
I've tried this on multiple versions of selenium 2 (from 2.24-2.28) and on two different systems. It's a very simple scenario. I want to run RC commands via Selenium Grid and I don't want to port my 1000+ test scripts to WebDriver, so hopefully that's not the only solution.
Test case:
1) START HUB:
java -jar selenium-server-standalone-2.28.0.jar -role hub
2) START NODE:
java -jar selenium-server-standalone-2.28.0.jar -role node -hub http://localhost:4444/grid/register
(I've tried every variation of this I could think of, including -role rc)
Communications seem fine between the two. The console status is up and shows the connection between the two.
3) REQUEST RC URL:
http://localhost:4444/selenium-server/driver/?cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
Output is always:
HTTP ERROR: 500
Problem accessing /selenium-server/driver/. Reason:
java.lang.NullPointerException
If I revert to non-grid mode, the request returns as expected.
Am I missing something or is RC simply not supported under Grid 2?
This seems to be fixed for *firefox as a browser in 2.30 however I still observe the same behaviour for *googlechrome
I fear this is a very trivial question. But I'm having some trouble getting selenium Grid2 to run multiple test against a single node, from my understanding this should be possible by setting maxSessions.
This is my setup:
-Hub runs completly standard
-Node runs firefox with 5instances and 5 sessions enabled.
I've created 6 dummy tests using MBUNIT and added [Paralizable] to make them run side by side.
This is what I've done to test:
1: Start 2 nodes and run all tests (they run in parallel one on each node)
2: Turn off nodeA and run all tests
In step 2 is where i get stuck, i expected the last node would run 2 tests at once since the maxSessions is set to 5 but this doesn't happen, it only runs 1.
I suspect I've used a wrong parameter when starting the hub or node somewhere but right now i can't figure it out. anybody who want to help a newbie at Grid2? :)
This is roughly my code, very basic just for playing around:
[TestFixture]
public class RemoteTest
{
[Test]
[Parallelizable]
public void StartClose()
{
DesiredCapabilities cap = DesiredCapabilities.Firefox();
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), cap);
driver.Navigate().GoToUrl("http://www.google.dk");
driver.Quit();
}
}
Commands used:
java -jar selenium-server-standalone-2.14.0.jar -role hub
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://192.168.0.26:4444/grid/register
no question is trivial :)
To start a server (use the following command)
java -jar selenium-server-standalone-2.14.0.jar -role hub
To start a Node (use the following command)
java -jar selenium-server-standalone-2.14.0.jar -role node -hub
http://localhost:4444/grid/register
Incase if u had tried to start a node with browsers as well (check the following command)
-browser browserName=firefox,version=3.6,maxInstances=5,platform=LINUX
maxInstances --> Signify the Max instances of same browser that can run on a Grid node
Selenium Grid: MaxSessions vs MaxInstances
If you specify capabilities in your test case that do not exist on your grid then there will be no match and the test will fail to run.
Please avoid running the tests from the Nodes and instead run tests from hub. I tried the same experiment where I ran the tests from the server (HUB) and I registered a node for running parallel test cases and everything worked perfect.