Download Required
1) selenium-server-standalone-ver.jar : All client machines and Server Machine
Steps :
Step 1 : Start the hub : Start hub on the Server machine with below command
java -jar selenium-server-standalone-2.28.0.jar -role hub
The hub will automatically start-up using port 4444 by default. To change the default port, you can add the optional parameter -port when you run the command. You can view the status of the hub by opening a browser window and navigating to: http://localhost:4444/grid/console
Step 2: Start the nodes : Regardless on whether you want to run a grid with new WebDriver functionality, or a grid with Selenium 1 RC functionality, or both at the same time, you use the same selenium-server-standalone jar file to start the nodes.
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://localhost:4444/grid/register
-browser browserName=firefox,version=3.6,maxInstances=5,platform=LINUX : This can be supplied .
For Windows : platform=WINDOWS
Note: The port defaults to 5555 if not specified whenever the "-role" option is provided and is not hub.
import java.net.MalformedURLException;
1) selenium-server-standalone-ver.jar : All client machines and Server Machine
Steps :
Step 1 : Start the hub : Start hub on the Server machine with below command
java -jar selenium-server-standalone-2.28.0.jar -role hub
The hub will automatically start-up using port 4444 by default. To change the default port, you can add the optional parameter -port when you run the command. You can view the status of the hub by opening a browser window and navigating to: http://localhost:4444/grid/console
Step 2: Start the nodes : Regardless on whether you want to run a grid with new WebDriver functionality, or a grid with Selenium 1 RC functionality, or both at the same time, you use the same selenium-server-standalone jar file to start the nodes.
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://localhost:4444/grid/register
-browser browserName=firefox,version=3.6,maxInstances=5,platform=LINUX : This can be supplied .
For Windows : platform=WINDOWS
Note: The port defaults to 5555 if not specified whenever the "-role" option is provided and is not hub.
Using grid to run tests
For WebDriver nodes, you will need to use the RemoteWebDriver and the DesiredCapabilities object to define which browser, version and platform you wish to use. Create the target browser capabilities you want to run the tests against:
DesiredCapabilities capability = DesiredCapabilities.firefox();
Pass that into the RemoteWebDriver object:
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
The hub will then assign the test to a matching node.
A node matches if all the requested capabilities are met. To request
specific capabilities on the grid, specify them before passing it into
the WebDriver object.
capability.setBrowserName(); capability.setPlatform(); capability.setVersion() capability.setCapability(,);
Example: A node registered with the setting:
-browser browserName=firefox,version=3.6,platform=LINUX
will be a match for:capability.setBrowserName(“firefox” ); capability.setPlatform(“LINUX”); capability.setVersion(“3.6”);
and would also be a match for
capability.setBrowserName(“firefox” ); capability.setVersion(“3.6”);
No comments:
Post a Comment