November 17, 2019

Start Selenium Grid (Hub-Node) from a single BAT file

  November 17, 2019
We can setup BAT file to start the selenium Grid , Start Hub in local host and to add Node to the hub.

For this to make simple we have to keep Selenium standalone server, Webdriver exe files, Hub/Node Config files and BAT files in the same folder.

I have added all these in the folder GridSetup and has added this folder to the project in below manner.


Content of start,hub and node BAT files are as given below

start.bat

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
SET USER=user
SET WD_PORT=5555

SET SSS=selenium-server-standalone-3.141.59.jar


SET IP=http://localhost
SET PORT=5555
SET THIS_FOLDER_PATH=%~dp0

for %%I in ("%THIS_FOLDER_PATH%\..\..") do set "AssemblyParent=%%~fI"
echo %AssemblyParent%

SET CHROME_DRIVER_FILE_PATH=%AssemblyParent%\<PROJECT_NAME>\bin\Debug\chromedriver.exe

cd %THIS_FOLDER_PATH%
start cmd /k "hub.bat"
call "node.bat"

hub.bat

1
2
3
4
title hub
TIMEOUT /T 5
java -jar %SSS% -role hub -hubConfig hub-conf.json -port %PORT%
TIMEOUT /T 15

node.bat


title node
TIMEOUT /T 5
java -Dwebdriver.chrome.driver=%CHROME_DRIVER_FILE_PATH% -jar %SSS% -role webdriver -nodeConfig win-node-conf.json -hub %IP%:%WD_PORT%/grid/register

We can execute this start.bat from BeforeTest/BeforeAssembly using process.start


logoblog

Thanks for reading Start Selenium Grid (Hub-Node) from a single BAT file

Previous
« Prev Post

No comments:

Post a Comment

Bookmark this website for more workarounds and issue fixes.

Verify Zip file contents without extracting using C# + Selenium

While doing automation testing, we may get a scenario where we need to download a zip file and to validate the contents inside it. One way t...