Webdriver execution explained | Ranorex Webtestit User Guide
WebtestitUser GuideWebdriver execution explained

The WebDriver execution explained

Selenium WebDriver utilizes a JSON-on-Wire Protocol (comparable to a REST service) which makes the automation framework communicate with a driver. A driver is an interface or executable that automates a web browser and ultimately your website or application.
Structure of this chapter
    Note icon

    Note

    The WebDriver remote control interface is currently in recommendation state by the W3C. All major web browsers on a desktop, tablet, and mobile support WebDriver.
    When you run a test, Selenium WebDriver connects to the configured host over IP. The automation framework retrieves information from the DOM of the website or app and returns which actions to execute.
    Note icon

    Note

    The computer running the test (i.e. evaluating elements and orchestrating actions) is not necessarily the computer serving as a host for the browser automating the SUT.

    Local and remote execution

    Testing your website or application means to ensure correct behavior according to its specification. In terms of web-based technologies, you also have to ensure this on a wide array of different platforms and browsers. Though there exist standards for the Internet, implementation of those is always subject to the individual browser manufacturer. What’s more is that new versions of different browsers are released in short cycles, with alterations to those implementations. The computer you use for designing tests is usually not capable of verifying multiple versions of the same browser without great efforts. Regardless of which platform/OS you use there is also no way to test across all browsers available on a single device. The simplest solution, therefore, is to have multiple platforms and browser versions at hand to automate your website or app on. Because Selenium WebDriver communicates with the browser driver over the network, you can switch seamlessly between local and remote execution. You can run the same test in different environments.

    Selenium server

    The Selenium Server is a host application running on a machine dedicated to testing. In its default configuration, it listens on port 4444 and accepts requests from automation frameworks to run tests. It serves as the bridge between your test and the web browser. You can set up your local network environment with multiple machines and target them individually. If you execute your test locally, Ranorex Webtestit launches a local Selenium Server instance and connects to it.

    Selenium grid

    Selenium Grid is a technology that abstracts a group of Selenium Servers into a single interface called a hub. A grid is a network of computers with OS/browser combinations ready for testing. Selenium grids allow you to scale your tests across a large number of environments and even parallelize them.
    tipp icon

    Hint

    You can either set up your own grid, or connect to grid providers. A grid provider is a service that operates a Selenium grid for you and takes care of all the necessary hard- and software to represent a sophisticated testing landscape.
    Ranorex Webtestit integrates with Sauce Labs as a grid provider. You can provide your Sauce Labs user name and access key to get going. If you are using a different provider, you can manually configure the necessary authentications through capabilities.

    Endpoints

    In Ranorex Webtestit you can define multiple configurations for running your tests on. A set of these options is stored in an endpoint.
    Note icon

    Note

    An endpoint is a JSON construct representing a collection of settings. These settings mainly consist of platform, browser and browser version. You can, however, narrow down on these attributes or set browser-specific options.

    About capabilities

    An endpoint hosts a set of configurations and options for the system under test. These configurations are referred to as capabilities. Every test scenario should be executed on some specific testing environments. Depending on the use case you can distinguish between required and desired capabilities. The desired capabilities help us to define which environment we are going to use in our test script. The automation framework will query the WebDriver to fulfil the capabilities specified and set up the target environment accordingly. If you, for example, specify Google Chrome as the browser, the target host will be searched for an instance of Chrome and launch it to automate the test on. If capabilities are not available on the local or remote host, your test run will fail.
    Note icon

    Note

    Ranorex Webtestit allows you to configure local endpoints only with detected WebDrivers and browser instances. This way you avoid configuration errors when working locally.
    You can find an overview of all capabilities supported by Selenium WebDriver here.
    { "platform": "macOS 10.12", "browserName": "safari", "version": "10.0" }

    Example for defining capabilities to test on macOS 10.12 and Safari version 10

    If you automate on a ⇢ Selenium grid the capability handling is usually more flexible. With multiple devices connected to the hub, the environment is filtered and narrowed down to meet the capabilities requested. The grid behaviour for capabilities gives you a lot of flexibility. Ensuring your website or application works on all browsers against a grid is a matter of defining browsers and executing them regardless of their version against the hub. In addition to the environmental requirements, you can also use capabilities to define settings for the target environment. Some of them are browser specific, like the option to enable and disable extensions. You can find an overview of browser-specific capabilities here.

    Managing endpoints in Ranorex Webtestit

    An endpoint can either target a single browser instance on your computer, or on a machine located remotely. Ranorex Webtestit differentiates between various types of endpoints that you can create and manage. The endpoints configured for your project can be found in the Execution tab.
    Endpoint file The currently selected endpoint configuration file. You can create and edit multiple endpoint files per project. Action Menu Enables you to create a new endpoint file, or delete the current one. + button Click here to add a new endpoint to the current configuration file. List selector Click here to select or deselect all endpoints for execution. Endpoint A single endpoint. Endpoint options Click here to edit or remove the endpoint. Run current test file Click this button to execute the currently active test file on all selected endpoints. This button is only enabled if a test file is opened. Run all test files Click this button to execute all test files in your project on all selected endpoints.
    tipp icon

    Hint

    Endpoints are stored in files that end with a .endpoints.json suffix. You can put them anywhere in your project structure. Ranorex Webtestit will locate and list them in the Execution tab for you.

    Adding and editing endpoints

    To add a new endpoint to your project, click the + button in the Execution tab. If you want to edit an endpoint, click the gear icon next to it on the list. In the pop-up dialog switch to the endpoint type you want to create or edit. Fill the fields as described below and hit Save endpoint to save your changes.

    Local endpoints

    Create local endpoints for testing on the same computer as you’re writing your tests. Ranorex Webtestit automatically detects installed browsers and can even connect to Android devices through adb.

    Reference

    If you want to test on a mobile device, click here to read how to connect an Android device.
    Field Description
    Name Provide a unique name for your endpoint. It will be displayed in the endpoint list and help you identify the endpoint.
    Platform & Browser Your endpoint is defined by the platform (operating system) and browser you want to test. You can choose between Desktop and Mobile platforms. Ranorex Webtestit automatically evaluates the browsers installed and lists them in the Browser dropdown. Note: For mobile testing, you need to have the Android Developer Tools and adb installed on your computer.
    Desired capabilities If you want to specify additional options for your environment configuration, you can type them as JSON code in this field.

    Remote browsers and Selenium grids

    If you have test machines in your network running a Selenium Server or Grid, you can use this option to connect and execute tests. With this, you can access other operating systems and/or browser versions than the ones you have installed on your computer.
    tipp icon

    Hint

    If you want to connect to a single remote machine, select the Selenium Grid option and specify the address to reach the computer without the trailing/wd/hub.
    Field Description
    Name Provide a unique name for your endpoint. It will be displayed in the endpoint list and help you identify the endpoint.
    Provider Selector Choose the provider of the hub you want to connect to. Sauce Labs requires additional authentication. If you choose Sauce Labs as the provider, you will be requested to enter your credentials.
    Desired capabilities Choose the environment you want to set up. Ranorex Webtstit automatically fills the available options after you click the Fetch available capabilities button.
    Note icon

    Note

    After entering the URL and credentials to your remote instance, click the Fetch available capabilities button. Ranorex Webtestit will query the endpoint for available OS/browser combinations.
    If you want to execute on your grid in parallel, you can define multiple endpoints for the same URL with different capabilities.

    Custom endpoints

    You can define a custom endpoint by providing a set of capabilities you expect from the remote system manually. Custom endpoints give you the flexibility to configure your remote machines exactly as you need them.
    Note icon

    Note

    Imagine having a set of different machines in a Selenium grid. If you request the hub to run on Firefox without any further definition, the first available machine with an active Firefox instance will be taken. The OS and OS version will not be taken into consideration, as you haven’t specified the capability. Whether the actual test run is executed on a Windows 10 or Windows 7 machine is not guaranteed.
    You can use the Ranorex Capabilities configurator to generate a JSON configuration manually.