0

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.

Idan
  • 33
  • 1
  • 9

1 Answers1

-1

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)

Vladimir Efimov
  • 797
  • 5
  • 13
  • Seems OP wants to initiate a _Selenium Server_ but not _Selenium Grid_ – undetected Selenium Oct 24 '18 at 07:59
  • Is this default true when only working with selenium standalone server and not the grid? I'm still having difficulties setting -maxSession and -maxInstance when using this command "java -jar /usr/local/bin/selenium-server-standalone.jar -role node -port 4001 -hub http://localhost:4444/grid/register -maxSession 5 &". I'm getting an "-maxSession unknown" error. Lastly, can you recommend a way to set up all these nodes with xvfb? my setup requires me to use it and I can't seem to get all of them to run with xvfb-run. Thanks! – Idan Oct 24 '18 at 08:26
  • Oops, my bad for not clearly reading the question. I just checked the official docs to see what "Server" is and definitely my answer is about Grid. – Vladimir Efimov Oct 24 '18 at 10:59
  • Weird, because setting the server as a hub and setting nodes did work (just not with xvfb)... I definitely installed the standalone server... I'm now more confused than ever :) – Idan Oct 24 '18 at 12:14
  • @Idan could you please share what are your expectations of a "selenium server"? I always thought of it in context of a grid, which supposes to run a single hub and at least one node. Frankly speaking, i miss the source of your confusion... so anymore details are welcomed :) – Vladimir Efimov Oct 24 '18 at 12:51
  • found https://stackoverflow.com/questions/24303909/what-is-the-difference-between-running-the-selenium-standalone-server-and-hub-no so initially you would like to just run a server without nodes and run multiple tests on it. I wasn't able to quickly find docs for configuring 'just server' in the official site. So maybe you just should use hub+nodes as it is stated as a more flexible configuration? – Vladimir Efimov Oct 24 '18 at 12:53
  • I just downloaded Selenium Standalone Server and ran it, per script here https://gist.github.com/ziadoz/3e8ab7e944d02fe872c3454d17af31a5. I'm open to working with hub-node configuration, I just can't seem to get both to work with xvfb-run. Without it, directly running it using java, causes the WebDriver script to generate errors as Chrome doesn't open without the virtual screen. – Idan Oct 24 '18 at 17:30
  • Running chrome in a headless mode may work for you. Add options to Google Chrome. The window-size is important for responsive sites ChromeOptions options = new ChromeOptions(); options.addArguments("headless"); options.addArguments("window-size=1200x600"); WebDriver driver = new ChromeDriver(options); – Vladimir Efimov Oct 25 '18 at 06:44