RemoteWebDriver Tutorial
Document Contents
Introduction
In this post, we will discuss RemoteWebDriver. First of all, Remote WebDriver is an implementation class of the WebDriver interface that can use to execute test code on a remote machine via the RemoteWebDriver server. Furthermore, there are two parts to RemoteWebDriver. Also, you can find a pictorial view of the concept in the below diagram.
1.Server.(Server is a Java servlet)
2.Client.( The client is your WebDriver test )
RemoteWeDriver Server
To Run the server
There are two ways to use the server: command line or configured in code.
To start the RemoteWebDriver server execute the following command on the remote machine.For example:
/> java-jar selenium-server-standalone<<Version>>.jar
The server has 2 different timeouts, which can be set as follows:
java -jar selenium-server-standalone-<<VERSION>>.jar -timeout=30 -browserTimeout=90
browserTimeout :Controls how long in seconds the browser is allowed to hang.
timeout : Controls how long in seconds the client is allowed to be gone before the session is reclaimed.
Note that : If the Webdriver tests forget to terminate the remote sessions, then the server might leak memory. If you keep long-running sessions, then probably we need to stop/quit the server every now and then or increase memory with -Xmx jvm option.
Server as Servlet
The process is as simple as mapping the DriverServlet to a URL.Also, it is possible to host the web page in a lightweight container, such as Jetty or dedicated App server container like Tomcat or JBoss, if you run the servers for other purphose.
Remote WebDriver client
When you execute your tests locally, the WebDriver client libraries talk to your FireFox Driver or Edge Driver. When you try to execute your tests remotely. Furthermore, the WebDriver client libraries talk to the RemoteWebDriver server and the server talks to either the FireFox Driver, Edge Driver etc
Code Snippet
public class SampleCodeExample { public static void main(String[] args){ DesiredCapabilities capabilities =new DesiredCapabilities (); capabilities.setBrowserName("Firefox"); RemoteWebDriver remotedriver =null; try{ remotedriver = new RemoteWebDriver (newURL("http:// 127.0.0.1:444/we/hub"),capabilities); } catch (MalformedURLException e){ e.printStackTrace(); } } }
You can view all of the sessions that are established with the RemoteWebDriver server by navigating to the default URL : http://127.0.0.1:4444/we/hub. ( However, we can configure this too according to our own needs ).
Selenium WebDriver Tutorials on this website can be found at:
https://www.testingdocs.com/selenium-webdriver-tutorial
For more details on the Selenium, visit the official website at: