Wednesday, May 23, 2018

First Steps into Automated Testing

Automated testing is buzzing around everywhere, so I decided to join the party. Below are the results of my first test.


For this test I used Robot Framework with Selenium Library. This is one of the best options to test a web application.

All the downloads and installation instructions can be found here:





Installing should be as easy as following the Readme’s in GitHub and you are able to find several tutorials through Google as well.

When your environment is ready to go, you can start making your first robot file.

Write your first test script 

Below is the robot file I created for this first test. The Test Case that I would like to run is to check if Acorel can still be found on Google.


*** Settings ***
Documentation           This is a simple test with Robot Framework
Library                 Selenium2Library


*** Variables ***
${SERVER}               http://google.com
${BROWSER}              Chrome
${DELAY}                0


*** Keywords ***
Open Browser To Google
   
Open Browser        ${SERVER}   ${BROWSER}
   
Maximize Browser Window
    Google Should Be Open
    Set Selenium Speed 
${DELAY}

Google Should Be Open
   
Location Should Contain    www.google.com

Search For Acorel
   
Input Text    lst-ib    Acorel
   
Press Key    lst-ib    \\13

Result Should Contain Acorel
   
Wait Until Page Contains    www.acorel.nl    10 s

*** Test Cases ***
Check if Acorel is still on Google
   
Open Browser To Google
    Search For Acorel
    Result Should Contain Acorel
   
[Teardown]    Close Browser

As you can see the robot file has several parts.

  • Inside the Settings you can add a description and include external libraries or other resources (i.e. robot files).
  • The Variables can be defined and used in the your Keywords.
  • Keywords are functions/methods that can be called from a Test Case or another Keyword.
  • Test Cases are (ofcourse) test cases that can be run with the framework.


Start the test 

Open the Terminal (or Command on Windows), navigate to the directory with your robot file and start the test with the command: robot example.robot


Chrome will open and the browser will navigate to Google.

The search field will be filled with Acorel and search will be performed.



A search for the website www.acorel.nl will take place, and if found the test will be successful.


In your Terminal you will see this screen when all checks are passed:



For more information you can see the generated log files, which shows exactly which step might have failed.



In case the check fails, you will see the following message:



The logging will show exactly what went wrong. The framework automatically makes a screenshot of the failed screen.



These we’re my first steps into automated testing. Hope you got some inspiration and are going to try it out yourself after reading this blog!