Build a web test

In this chapter, you’ll learn how to build a simple web test from start to finish, including recording the test, running it, and viewing the test run report.

In this chapter

    Test definition

    Our test will contain the following steps:

    Start the browser and open the URL www.ranorex.com/web-testing-examples/

    Check if the Ranorex Studio logo is displayed at the top.

    Click Open dialog.

    Click OK to confirm and close the dialog window.

    Close the browser.
    Note icon

    Note

    In automated tests, using the action Close application is usually more robust than closing an application “manually” by clicking the X in the application window. This is why the default web test project uses this action.

    Create a new web test

    We’ll create a new web test using the ⇢ RocketStart wizard.

    On the Ranorex Studio Start Page, click New test solution using wizard… or go to File > New > Solution using wizard…

    Click Web.

    Follow the instructions of the wizard. Name your solution WebTest. When prompted, select Mozilla Firefox as your browser (make sure it’s installed on your computer) and specify www.ranorex.com/web-testing-examples/ as the URL.

    When asked to select the recording behavior, select Add browsers to whitelist, as our test will only cover interactions with the previously selected browser. If we were going to interact with desktop applications and wanted this in our test, we’d select Do not use whitelisting.

    On the final screen, click Finish. Ranorex Studio will then open the prepared solution.

    The prebuilt web test will look like this:

    Test suite view
    This is where you build and control your tests.

    The solution comes with a test suite project that contains a simple prebuilt test suite structure. It contains a test case with three recording modules: OpenBrowser, which starts the browser and navigates to the URL; Recording1, which is empty and ready for you to record test actions; and CloseBrowser, which closes the browser.

    Recording module view
    In the recording module view of Recording1, you can record and manage test actions.

    Empty actions table
    This is where your recorded actions appear.

    Record the test

    Before you start recording, make sure Firefox is running and the URL www.ranorex.com/web-testing-examples/ is opened. Don’t record these steps. They are already included in the prebuilt project.

    Once that’s done, you can start recording.

    In the recording module view, Click RECORD. Ranorex Studio is minimized.

    The Recorder control panel appears in the bottom right.

    Validate the logo

    In the control panel, click Validate.

    Mouse over the Ranorex Studio logo and click it when the purple frame surrounds it as in the screenshot.

    The Select element window opens. Check if the correct image has been selected and click Next to confirm.

    The Validation settings open. We’re checking that the logo exists and is visible. Both of these attributes should already be selected. Click OK to confirm.

    Open and confirm the dialog window

    In the browser, click Open dialog. A simple dialog window opens.

    Click OK to confirm and close the dialog.

    Finally, in the Recorder control panel, click Stop to finish the recording.

    Results

    The control panel disappears and Ranorex Studio comes back into focus, showing the following:

    Action table with three recorded actions.

    Repository with repository items referencing the three UI elements interacted with during the recording.

    Run the test and review the report

    Let’s run the test and review the test run report.

    Close all instances of Firefox.
    Click the tab WebTest.rxtst to switch to the test suite view and click RUN.

    Report

    Once the test run has finished, the report will appear. In our case, it should look like this:

    A detailed view of the test case shows that all actions were executed successfully.

    Reference

    Reports are explained in

    Ranorex Studio fundamentals > ⇢ Reporting