Robot Framework is a good automation tool for both large and small businesses. The shallow learning curve makes it easy for companies to implement automated testing. This article shows how to perform automated testing of a website without using any code.
Basic knowledge of Selenium
Knowledge of Robot Framework
Computer with macOS, Windows, Linux, or Unix. This article will show the Mac setup.
Python 3.5+
Robot Framework
Selenium Chrome WebDriver for Chrome version installed
PyCharm
This project is a simple automated testing demo application. The demo will test the five features of Topcoder’s home page.
Open PyCharm.
Install the plugins – PyCharm -> Preferences -> Python Interpreter ->
Install:
Selenium 3.141.0
robotframework 4.0.0
robotframework-pythonlibcore 2.2.1
robotframework-seleniumlibrary 5.1.3
robotframework-selenium2library 3.0.0
robotframework-dependencylibrary 1.0.0.post1
webdrivermanager 0.10.0
Robot Framework Support
Create a new project named TopcoderAutomationDemo – File -> New Project.
Create three new directories: Resources, Results, Tests – Right-click on the project name -> New -> Directory
Create seven files in the Resources directory: Common.robot, ContactUs.robot, HomeNav.robot, ListChallenges.robot, Login.robot, PlaybookAlert.robot, and Signup.robot – Right-click on Resources directory -> New -> File
Create one file in the Test directory: TCDemo.robot – Right-click on Tests directory -> New -> File
The test scripts will use the Selenium library keywords. The test script files are in a module fashion. Creating different test scripts makes it easy to change the keywords when the website changes.
Test that the navbar and its items are present.
Test that the Contact Us form appears after clicking the link on the home page.
Test that the user can navigate to the Topcoder challenge page from the home page.
Test that a user cannot log in with an invalid username or password.
Test that a user cannot sign up for a Topcoder account with an existing Topcoder handle or username.
Following the DRY (Don’t Repeat Yourself) principle, functions used by multiple script files are in Common.robot. The file has the Settings and Keywords sections. Each test case launches and closes the browser.
Scenario
Open browser – the start of the test case,
Maximize browser,
Close playbook alert - It is a bad idea to flood the server of a live website with multiple requests for information.
Close browser – end the test case.
Figure 1 – Common.robot test script
PlaybookAlert.robot contains the keywords to close the playbook alert. The file has the Settings and Keywords sections.
Scenario
Set an implicit wait.
Close the alert.
Figure 2 – PlaybookAlert.robot test script
HomeNav.robot contains the keywords to check if the navbar and navbar items are displayed. The file has the Settings and Keywords sections.
Scenario
Check to see if the navbar is visible.
Check to see if the items in the navbar are: How It Works, Platform, Industries, Resources, Pricing, Book a Demo, The Community, Log In, and SignUp.
Figure 3 – HomeNav.robot test script
ContactUs.robot contains the keywords to display the contact form. The file has the Settings and Keywords sections.
Scenario
Scroll to the bottom of the page.
Click on ‘Contact Us’.
Check to see if the contact form page opens.
Go back to the home page.
Figure 4 - ContactUs.robot test script
ListChallenges.robot contains the keywords to display all open challenges. The test script navigates to the challenge listing page from the home page. The file has the Settings, Variables, and Keywords sections.
Scenario
Click on ‘The Community’.
Check to see if the community page displays.
Click on ‘FIND A CHALLENGE’. The challenge page opens in a new browser window.
Switch to the challenge listing page browser window.
Check to see if the community page is displayed.
Figure 5 – ListChallenges.robot test script
Login.robot contains the keywords to login to an existing account with an invalid username or password. The file has the Settings, Variables, and Keywords sections.
Scenario
Click on ‘Log In’.
Wait until the page fully loads.
Check if the login page displays.
Enter the username and password.
Click the submit button.
Check if the user received an error message.
Figure 6 – Login.robot test script
Signup.robot
Signup.robot contains the keywords to sign up for a new account using an existing username. The file has the Settings, Variables, and Keywords sections.
Scenario
Click on ‘Sign Up’.
Wait until the page fully loads.
Check if the sign-up page displays.
Click on the talent button.
Enter the first name, last name, email address, username, and password.
Select the country.
Select the checkbox.
Verify the checkbox is checked.
Click the submit button.
Check if the user received an error message.
Figure 7 – Signup.robot test script
TCDemo.robot contains the keywords to run the test cases. The file has the Settings, Variables, and Test Cases sections. The Settings section imports the other test scripts and uses the test setup and teardown. There are two types of setup and teardown commands: Suite Setup, Suite Teardown, Test Setup, and Test Teardown. Suite Setup and Suite Teardown execute at the beginning of the tests and after the last test case run. Test Setup and Test Teardown execute at the beginning of each test case. This project uses Test Setup and Test Teardown.
Figure 8 – Signup.robot test script
Open a terminal window in PyCharm. At the command prompt type robot -d results tests/tcdemo.robot. The -d instructs the compiler to store the results in the Results directory. After the test suite finishes, the Result directory contains the log.html, output.xml, and report.html files. You can view the log.html or results.html file in the browser by right-click -> Open In -> Browser -> Chrome.
Figure 9 – Project report.xml file
Figure 10 – Project log.html file
Congratulations! You created a Robot Framework project from scratch using no code. Here are the links for the source code and video demonstration of the project.
Enjoy!
https://pixabay.com/vectors/bot-icon-robot-automated-cyborg-2883144/
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html