How to robotize testing your APEX applications

28-03-2023 • Boyd Timmerman

Test automation using robot framework

Oracle APEX is a low-code web application development platform that allows developers to quickly build robust applications. However, as with any software application, testing is an essential part of the development process to ensure that the application works as intended. In this blog, we will explore how to perform automatic testing of Oracle APEX applications using the Robot framework.

Robot framework

The Robot framework is an open-source, keyword-driven test automation framework that allows testers and developers to create, run, and manage automated test cases in a structured and organized manner. It was initially developed for acceptance testing, but it can also be used for other types of testing, such as functional, regression, and unit testing.

The Robot framework is built on top of Python, and it uses a plain-text format for test case and keyword definition. This format is known as the Robot Framework Test Data Syntax, and it provides an easy-to-use and human-readable syntax for defining test cases and keywords.

Test cases in the Robot framework are organized into test suites, which can contain one or more test cases. Each test case is defined using a structured format that includes sections for settings, variables, test cases, and keywords.

The Robot framework comes with a set of standard libraries that provide keywords for performing various types of testing, such as the SeleniumLibrary for web testing, the DatabaseLibrary for database testing, and the SSHLibrary for testing using SSH connections.

In addition to the standard libraries, the Robot framework supports the creation of custom libraries, which allows users to extend the functionality of the framework by defining their own keywords.

To execute test cases in the Robot framework, you can use the Robot command-line tool, which allows you to specify the test suite or test case file to run, as well as various options for controlling the test execution, such as output format, logging, and variable assignment.

When you run a test case using the Robot framework, the framework executes each step in the test case in order and reports the results of each step, including any errors or failures that occurred. The Robot framework also provides a detailed log file and report file that can be used to analyze the test results.

To start using the Robot framework for testing Oracle APEX applications, you need to install the Robot framework and the SeleniumLibrary. SeleniumLibrary is a Robot framework library that provides keywords for web testing. You can install both using pip, a package manager for Python. Full install instructions can be found here. Once you have installed the required libraries, you can start writing your test cases.

Creating a test

Let’s consider a simple example of testing a login page of an Oracle APEX application using Robot framework.

*** Settings ***
Library           SeleniumLibrary

*** Variables ***
${BROWSER}        chrome
${LOGIN_URL}      https://myapp.com/ords/r/myschema/myapp/login

*** Test Cases ***
Valid Login Test
    Open Browser    ${LOGIN_URL}    ${BROWSER}
    Input Text      username        myusername
    Input Text      password        mypassword
    Click Button    Sign In
    Wait Until Page Contains    Welcome

Invalid Login Test
    Open Browser    ${LOGIN_URL}    ${BROWSER}
    Input Text      username        myusername
    Input Text      password        wrongpassword
    Click Button    Sign In
    Wait Until Page Contains    Invalid username or password

In this example, we have defined two test cases: a valid login test and an invalid login test. The test cases use SeleniumLibrary keywords such as Open Browser, Input Text, Click Button, and Wait Until Page Contains to interact with the login page of the Oracle APEX application.

In the Valid Login Test, we open the login page, input the username and password, click the login button, and wait until the page contains the Welcome message, indicating that the login was successful. In the Invalid Login Test, we input a wrong password and wait until the page contains an error message.

You can run these test cases using the Robot framework command line interface.

robot --outputdir results mytestcase.robot

This will execute the test cases defined in the mytestcase.robot file and generate a report in the results directory.

In addition to web testing, you can also integrate the Robot framework with continuous integration tools such as Jenkins to automate the testing process.

Conclusion

In conclusion, automated testing is a critical part of the software development process, and the Robot framework provides an easy-to-use, flexible, and extensible testing framework that can be used to test APEX applications. By writing automated tests, you can ensure that your APEX application works as expected, and catch issues before they make it into production.