A Practical Guide on Automating Salesforce testing with Robot Framework
Robot framework is an open-source automation framework, and it is implemented by Selenium with Python. It is executed by Jython (JVM) and Iron Python (.NET). Robot Framework is an automation framework for acceptance testing and acceptance test-driven development testing.
The Robot framework supports data driven, keyword driven, and table-driven methods
- Robot framework supports advanced keyword driven framework
- Dynamic variables are used, and scripts and custom keywords are reusable
- It supports test libraries including Selenium
- It is an open-source framework
- It provides simple and powerful test reports
Pre-requisite for Robot framework:
Python should be installed with Selenium Installation, and then the robot framework and RIDE should be installed with python.
Executing Robot framework with python using “robot” scripts. The scripts are executable in the automation framework system.
RIDE can be open as a windows command as ride.py.
This is the RIDE editor normal view. Here, we can import files like standard & external library, resource files, variables, Scalar variable, list and dictionary using the add import setting option.
Create a new lead record and convert the lead record; then verify the Lead values are mapped with Accounts, Opportunity and Contacts object fields.
We can import library files and resource in RIDE using setting option.
RIDE has standard and external library files; so, we can import as per our requirement.
Resource setting method is used to import extra files like reading data from excel action and any other complex method implementation can be developed a code in python file and import it as a resource file.
Step2: Identify and capturing the Web element.
To identify the web elements through inspect/fire path and update the web elements using the scalar variable method.
Adding a scalar variable with web elements
The scalar variable contains web elements of the Lead, Account, Opportunity and Contacts object. Please see the screenshot below:
We can use this scalar variable in all test cases inside of same test suite.
Test case creation:
We can prepare test document like functionality and test steps, using setting option.
Setup and Tear-down:
Tag: Tags are generally more flexible and provide more functionality than documentation, we can tag test cases and run at necessary test execution.
In Robot framework, the test cases are written by two methods:
- Work flow test
- Data driven test
New User Keyword:
By right clicking test suite, we can create a new user keyword. The keyword should have argument names and clear structure about the test cases.
Below is the example of user keyword method
Test Case: By Right clicking the test suite, we can choose the new test case drop down and write the test cases in a tabular syntax method. The test cases are written easily by using this method.
Text view of test cases:
Once have completed the test case development, click Save icon on the top window; then, execute the test cases.
Test Execution and Test Results:
After executing the test cases, these three files are generated: Log, Report and XML files. The test results would be very clear and detailed. It generates the compiled report with a step-by-step execution detail.
Among the executed test cases, two test cases passed and other two test cases failed, also the test execution result could be generated in run tab with console
Console window of RIDE
Test Log Report:
It is a log report of test execution.
Failed Test Log Report:
When executing the test cases, if any issues are identified, they are automatically taken screenshot with a detailed description.
Robot framework generated detailed reports about test execution with time duration and status %.
Robot framework Advantages:
- Less effort to automate the test cases
- It supports Continuous Integration and easy integration with other tools
- It supports exception handling and test executions are supported by different operating system
- Test matrices updated automatically.
- Failed test cases can be captured as defect screenshots with detailed descriptions.