Robot Framework – An Unglorified Hero

PART – 2

In case you missed Part 1

Writing the First Test case in the robot framework

  1. Open the Eclipse editor, create a new project and save it in your desired location.
  2. Right-click on the created project and create a new folder. Give a project name and save it.
  3. Right-click on the created project and create a new file. Name and Save the file with a filename with .robot as an extension.
  4. The test script will contain keywords, the locators of the elements in the page and the library resources information that is being used in the script.

Sections of Testcase

• Includes documentation of the suite, specifying more details about what the test is all about.
• Library name – Includes the built-in library name and the customized library name that the programmer has coded in use
• Resource name – Includes the other repository files or the utility files that the programmer want to use it in the script
• Suite Setup/Suite Teardown- This is to close the Test suite after test execution.

• Variables used in the script

Test Cases
• Actual Testcases
• Tags-Tags could be specified to mention if the test is of Sanity, functional etc. Basically, you are tagging the test to something.

These are your actual methods written in the form of keywords to test the functionality.
Below depict the sections of your test case.

Run the Tests and Analyze the results

  1. Right-click on the intended test to be run
  2. Click on the option Run As from the menu
  3. Click on the option Robot Test from the submenu

Below is the screenshot

The results of the executed/run test case get displayed at the bottom of the console page:

Robot Test Reports

The test execution results are displayed to the user with a neat HTML format, although one can customize the test reports format, on the need basis. Now we will see how the generated test result report would look like and how informative it could be for any further assessment!

If all the tests pass, the report would be in green. If any of them fail, the report will be red. The results will get displayed in sections segregated by statistics, by Tag statistics, by Suite, etc.

You can click on the log file for a more detailed summary.

If interested in more test result details, click on the intended test:

Organizing your Project files

Organize your project files such that the pattern supports the Page Object Model pattern.

The Page Object Model is easier to maintain. as each test will be classified to the corresponding page elements. Therefore, the organized structure will be a page repository for the elements in the page.

The script file has the test cases, and the keywords have the lower level methods that the script must do. And the page objects that have the locators of the web elements of the pages

The Folder structure would be, as below:
/Pages (Contains all the locators to the elements of the corresponding page and the methods or actions that’s being formed on that page)
• MyFirstTestPage.robot

/Resources (Contains the common utilities or keywords that you want to use)
• Common.robot

/Tests (Contains actual test methods)
• TestFirstTestLogin.robot

/Results (Contains the results captured of the tests post run)
• Result

/Libraries (Contains Customized libraries, using Python)

Exploring the libraries…

  1. The built-in libraries already have so many valued/robust keywords, that could be used in your scripts. Please refer here for more details on the keywords inside a built-in library.
  2. Dialog libraries: This library gives a dialog that pops out the window to capture user response. Go to this page for more details on the dialog library.
  3. Operating system libraries gives the abilities to manipulate the files, directories, copy, modify, etc.
  4. Similarly, there are various other libraries, related to API, MySQL…etc.
  5. Below gives the idea of various libraries that the robot framework can provide

However, one can write their own set of libraries using python and use it in the script. This is a very rare necessity, as the robot framework standard and external libraries themselves contain a lot of keywords that can be of great help.

So, that’s how it makes our Robot framework more robust!


Please enter your comment!
Please enter your name here