Intro Selenium

Selenium is a collection of language specific bindings used to automate tests carried out on a web browser. Testerum takes the Selenium library to the next level of accessibility and versatility. Forget using the programming script of your browser, you don’t need it anymore. Testerum comes with Selenium integration and a selection of pre-built Selenium steps, you just have to choose what suits your requirement. Navigate to Steps in the header menu and select Basic Steps => selenium to see the available set of steps: actions, assertions and wait.

Selenium Steps

Find elements in the DOM

For the Selenium steps that contain <<elementLocator>>, you will have to target a particular HTML element on the page. For these parameters you need to use an expression with the following syntax: elementLocatorType = elementLocatorExpression

The elementLocatorType can be one of following:

The part elementLocatorType= is optional. If it's missing, the locator type will be CSS. For example,
nav > .home will match elements with the CSS class home that are direct children of a nav element. Tip: If multiple elements match, a step will choose only the first one, unless noted otherwise in the step's description.

Find elements using CSS selectors

Assuming you have to target some elements in the DOM using CSS selectors go to your tested page, open the developer console and find your target.
Once you found the target, add it inside Testerum:

CSS selectors CSS selectors

Find elements using XPath expressions

In Selenium automation, if the elements are not found by the general locators like id, class, name, etc. then XPath is used to find an element on the web page. The basic format of XPath is explained below:

XPath Expressions Definition

In Testerum looks like this:

XPath Expressions Definition

Cross Browser Testing

A web application can be opened in any browser by the end user.
Cross Browser Testing is a type of functional test to check that your web application works as expected in different browsers.

Cross Browser Testing

How to perform Cross Browser Testing with Testerum

To execute test cases with different browsers in Testerum you have two options:

1. You can open current settings and choose the browser

Cross browser testing settings  Cross browser testing settings

2. Create Selenium Custom Configurations

Setting up configurations will allow you:
- to specify the desired browser to run the tests
- to include or exclude different tests to execute
To create a configuration in Testerum, you will find in the middle of the navigation bar 'Add Run Config':

Run Configuration

Go to 'Selenium' Tab and select the last options for this configuration

Run Configuration Selenium Tab

Now you are ready to execute the tests with this configuration

XPath Expressions Definition

Headless Mode

There are cases when you may need to run automation tests in ‘headless’ mode, i.e., when no browser is being displayed. In these cases, you can execute Selenium tests in headless browsers. A headless browser is a browser simulation program that does not have a user interface.
These programs operate like any other browser, but do not display any UI. When Selenium tests are run, it executes in the background.
Three Benefits Of Headless Browser Testing
1. Improves speed and performance
Since this type of testing does not actually open a browser, the system saves the processing power that would otherwise be used in a real browser test. Consequently, the tests are executed faster.
2. Allows testing browserless setups
There may be setups where installing a browser is not possible, such as servers. In these cases, headless browsers help run automation tests easily.
3. Helps you multitask
You can use your browser or your machine to do anything else while the tests run in the background. Save hours of time that is otherwise spent staring at the screen.

How To Run Selenium Tests In Headless

You can execute the tests in headless mode weather from Settings or from your own configuration.

Parametrized Steps

Or modify your run configuration like this:

Parametrized Steps

Parametrization

Parametrizing your test steps makes tests more robust and you more efficient.
First, lets consider a positive login test where values are hardcoded in the step definition.
In order to verify the login functionality with other input data we have to create
again and again the same test, but every time with a new step definition.

Parametrized Steps

Here comes the benefits of parametrizing the test steps.
We transform the second step "When I fill in 'admin' as user name and 'test123' as password" by replacing
'admin' with a parameter called <<userName>> and 'test123' with <<password>>
For this we have to edit the step

Parametrized Steps

And replace the hardcoded values 'admin' and 'test123' with parameters.

Parametrized Steps

After adding the parameters <<userName>> and <<password>>, these can be accessed
inside the implementation steps(Basic Steps) by enclosing them inside double curly brackets
{{userName}}, {{password}}

Parametrized Steps

Now, the step definition should look like this:
When I fill in <<userName>> as user name and <<password>> as password
It has two parameters which are waiting some values.

Parametrized Steps

Once you assign values to the parameters, the implementation step will access these values at runtime.
At runtime, the expresions {{userName}}, {{password}} will be evaluated.

Parametrized Steps

At this point, basically we are done with the parametrization of this step.
From now on, you can simply reuse it and add different input data.

Parametrized Steps

Notice: Parametrization merged with Scenario Outline will make your tests very robust.

Scenario Outline

This keyword lets you run the same scenario for two or more different input data.
Writing multiple test cases(scenarios) to cover different inputs can be quite tedious.
In time it becomes harder to maintain these tests and quite frustrating.
In Testerum, we come up with "Scenario Outline" concept which allows you to create multiple
scenarios for a test case.
To add a scenario to your test, press the Scenario + button.

Parametrized Steps

The Scenario Outline facilitates performing scenario with several examples.
Add the parameters you want to be accessed during the test execution.

Parametrized Steps

Set names and values for your parameters.

Parametrized Steps Parametrized Steps

There is no need to lose time writing again ang again the same test case which contains different input data.

Scenarios

Scenario outline has provided a cleaner approach to keep the feature file small and more readable,
instead of writing similar kind of scenarios repeatedly.
Follow this approach and you will reduce significantly the effort in writing and maintaining automated tests.

Scenarios

Add a new Selenium driver

Introduction

Testerum comes bundled with Selenium drivers for the most popular browsers (Chrome, Firefox, Safari, Internet Explorer, Edge, and Opera). From time to time, browser vendors release a new version of their browser that no longer works with the latest version of the Selenium driver that Testerum has. At the same time, browser vendors also release a newer version of the Selenium driver which works with the new browser version.

When this happens, you can either wait until a new Testerum version will be released, which includes the new driver, or download the new driver yourself, and let Testerum know about it.

How to add a new Selenium driver to Testerum

  1. First, you will need to download the new Selenium driver. You can do that from one of the following places:

    Note:
    • There is no need to download the Selenium driver for Safari - it comes installed together with the Safari browser.
    • Since there will be no new versions of Internet Explorer (the last version is 11), there is no need to download new drivers for it.

  2. After downloading the driver, extract the executable file (e.g. operadriver.exe) from the downloaded archive in a directory where you have write access.

  3. Rename the executable file to contain the platform and the version, e.g. operadriver_win64_75.0.3770.100.exe. For the platform part, use win64, mac64, or linux64, depending on your operating system.

  4. In the same folder as the extracted driver, create a text file with the same name as the driver file, but having the .json extension: operadriver_win64_75.0.3770.100.json.

    The content of the file should have the following format:

    {
        "driverFile": "operadriver_win64_75.0.3770.100.exe",
        "driverVersion": "75.0.3770.100",
        "browserVersions": ["61", "62"]
    }
    The driverFile specifies the name of the executable file.
    The driverVersion is the version of the driver.
    The browserVersions lists all the browser versions supported by this driver.

  5. Copy the executable file (operadriver_win64_75.0.3770.100.exe) and the JSON file (operadriver_win64_75.0.3770.100.json) to the Selenium drivers directory, for example C:\Program Files\Testerum\selenium-drivers\opera.

  6. Restart Testerum so it can pick up the new driver.