TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Selenium

RemoteWebDriver Tutorial

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.

There are two parts to RemoteWebDriver

  • Server.(Server is  a Java Servlet)
  • Client.( The client is the WebDriver test )

Servlet is a Java class that runs in a Web container. Class diagram of RemoteWebDriver

 

Selenium API

RemoteWebDriver 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

 

 

Selenium Grid Standalone

 

 

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. This is the case with limited hardware resources.

Docker Containers

We can fix these issues by running scalable and distributed grid on Docker containers.

https://www.testingdocs.com/scalable-selenium-grid-with-docker-compose/

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 purpose.

Remote WebDriver client

When you execute your tests locally, the WebDriver client libraries talk to FireFoxDriver /ChromeDriver/EdgeDriver etc.

When we try to execute the tests remotely, the WebDriver client libraries talk to the RemoteWebDriver server and the server talks to either the FireFoxDriver, ChromeDriver, Edge Driver etc on the Node machines/containers.

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 (new URL("http://
127.0.0.1:444/we/hub"),capabilities);
 } catch (MalformedURLException mfe){
 mfe.printStackTrace();
 }
 }
}

 

To customize the browsers and their capabilities consider using FirefoxOptions, ChromeOptions, etc. to run remote Web driver tests.

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 ).

Note that this is old and classic standalone mode. The architecture has significantly changed with Selenium 4 with new Distributed mode that we can leverage some of the limitations and disadvantages.

https://www.testingdocs.com/selenium-grid-distributed-mode/

—

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:

https://www.selenium.dev/

Related Posts

Windows 10 Settings

Selenium /

Add Microsoft Webdriver on Windows OS

Download Selenium Components

Selenium /

Getting Started with Selenium Webdriver

LambdaTest Testing Cloud SaaS Platform

Selenium /

LambdaTest – Testing Cloud SaaS Platform

Selenium /

Selenium 3.0 and Mozilla GeckoDriver

SauceLabs Website

Selenium /

Run an Example Test on SauceLabs

‹ Run test using RemoteWebDriver with Marionette› Find elements using Selenium Locators

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com