In previous posts, We have seen how to set up hub and nodes. But still we have not seen how to run your code on some remote machines.But code execution on remote machine could not be possible without RemoteWebDriver. But before moving ahead we need to cast our focus on this RemoteWebDriver.
\ This is implementation class of WebDriver interface which is plays a key role in script execution on some remote machine.RemoteWebDriver is divided in two parts
1- RemoteWebDriver Server
2- RemoteWebDriver Client
RemoteWebDriver Server : This part listen all the request on certain port from all the RemoteWebdriver client and on the basis of these request it approach Firefox, Chrome or IR driver to fulfill client request. So here when we run this command
we try to start the remote server.
RemoteWebDriver Client : All the language binding works as RemoteWebDriver client which comes in to action when we try to execute any script. These client first try to translate all the information related to code execution in JSON formate and send it to remoteWebdriver server using JSON wire protocol and then server talks to all the drivers available as per the request.
So now you are familiar with the concept of RemoteWebDriver but how it servers your purpose.
As you have already seen that RemoteWebDriver is implementation class of WebDriver and in your Selenium WebDriver script you always create a driver instance that talk to respective browser as per our code. In the same fashion you need to create instance of WebDriver like this
where URL is nothing but the it is URL of Hub that we have used in previous post like so here URL would be (as per above image) URL = http://192.168.0.104:4444/wd/hub Capabilities is nothing but used to provide information about the configuration which contains type of browser, version and also provide information about platform where script should be executed remotely.So lets see how to it is being used , Suppose you want to execute your code on firefox with version 40.0 and want to run this test on node machine which is Windows
So Capability would be written like this
Above code will execute complete scenario on Windows machine with Firefox browser with version 40.0.
This was the first code that will be used for grid example. In coming post you will see how you can run your script on multiple machines at the same time and would see how parallel execution of test cases are possible with Selenium Grid.