We are very excited to announce that starting from today, you can work on your Robot Framework tests you love straight from TestProject‘s platform! π€ If you are a true fan of Robot, KDT, Python and Selenium you can finally have your Robot KDT repots on TestProject’s cloud dashboard, with just one simple line π
pip3 install testproject-robot-library
Table of Contents: TestProject π Robot Framework
- Why use the TestProject Library for Robot Framework?
- Prerequisites
- What is Robot Framework
- Create a New Test using the TestProject Library for Robot Framework
- New Test Suite Using the TestProject Library for Robot
- Robot KDT Reports you love are now in the cloud
- Watch live demo recording! β¨
Why use the TestProject Library For Robot Framework?
TestProject offers a set of tools for creating end-to-end tests:
- TestProject Agent handles the deployment and configuration of Selenium/Appium.
- Keeps you up to date with the latest stable versions of Selenium/Appium drivers.
- Cloud team collaboration and automatic test reports (HTML/PDF/JSON).
- Codeless test recorder allows creating and running tests without a single line of code.
- Code extract feature, which allows you to generate Selenium/Appium code from your codeless tests.
- Coming soon: Automatic deployment of your Robot tests across multiple targets by TestProject Agent (complete CI/CD experience).
By integrating this library with your Robot Framework tests, you can enjoy all these advantages, as well as fully automated Robot KDT reports (with screenshots) hosted for free on the TestProject platform.
Combining the TestProject Library with Robot Framework is as simple as using the SeleniumLibrary. It’s implementing the same syntax, replacing only the “Open Browser” keyword.
Prerequisites
Before getting starting, just make sure to complete the following:
- Login or create a new free TestProject Account.
- Download and Install the TestProject Agent.
- Register the Agent, and get your developer token from here.
- Install the Robot Framework:
pip3 install robotframework
, or following the installation instructions here. - Install the TestProject Library for Robot:
pip3 install testproject-robot-library
.
What is Robot Framework
Robot Framework is a generic open source automation framework. It can be used for test automation and robotic process automation (RPA).
- Robot Framework has easy syntax, utilizing human-readable keywords.
- Its capabilities can be extended by libraries implemented with Python or Java.
- The framework has a rich ecosystem around it, consisting of libraries and tools that are developed as separate projects.
You can read more on Robot Framework in the following blogs & tutorials:
- Robot Framework Introduction β Simplify your Test Automation Process
- Top 8 Python Testing Frameworks in 2020
- Robot Framework: Tips for Writing Automated Test Cases
- Create a Test Automation Environment with Appium, Robot Framework & Jenkins
Create a New Test using the TestProject Library for Robot
The first thing we need to do is create a new Robot test file. Let’s call this file MyRobotTest.robot
. Since we’re going to use the TestProject Library for Robot, we must declare it inside the test:
*** Settings *** Library TestProjectLibrary
Once the TestProject Library for Robot is declared, we can use its full functionality.
Next up, let’s create a Suite Setup
section for initializing the TestProject Driver:
Suite Setup InitTestProject *** Keywords *** InitTestProject Init Testproject Driver chrome timeout=5000 job_name=TestProjectRobot Open Browser https://example.testproject.io/web/
In this snippet, we declare a custom Keyword named InitTestProject
which creates a new session with the TestProject Agent, requesting to open a Selenium session on a Chrome browser.
π‘ Under the *** Keywords ***
section we can put all of our custom keywords.
Init TestProject Driver is the most important part of the TestProject Library for Robot. It communicates with the TestProject Agent and passes any Desired capabilities, browser type, timeouts and additional data that is required by the TestProject Agent.
π‘ This method replaces the Create Webdriver
and Open Browser
keywords, and is the only difference between the SeleniumLibrary and the TestProject Library for Robot.
Since the TestProject Library for Robot was created as a wrapper for the SeleniumLibrary, you can simply take your existing Robot tests, replace the import of the SeleniumLibrary
with TestProjectLibrary
, call the Init TestProject Driver
keyword and you are good to go! πͺ
The following Selenium test:
Library SeleniumLibrary Open Browser browser=Chrome url=https://example.testproject.io/web/ Create Webdriver driver_name=Chrome
Changes to:
Library TestProjectLibrary Init Testproject Driver browser=Chrome url=https://example.testproject.io/web/
That’s it! π€©
New Test Suite Using the TestProject Library for Robot
In this section, we will create a simple test suite with 4 tests:
- Login with an incorrect password
- Login with a correct password
- Filling in a form with some details
- Submitting the form
The suite is built to run on TestProject’s example website: https://example.testproject.io/web.
Here is the complete Robot test:
*** Settings *** Library TestProjectLibrary Suite Setup Init Session Suite Teardown Close Session *** Test Cases *** Set Session ${previous kw}= Register Keyword To Run On Failure None Login With Incorrect Password Base Login ${INCORRECT_PASSWORD} Login With Correct Password Base Login ${CORRECT_PASSWORD} Fill Form Select From List By Label css:#country Australia FOR ${input} IN @{INPUT_ELEMENTS} Input Text ${input} ${INPUT_VALUES}[${INDEX}] ${INDEX}= Evaluate ${INDEX} + 1 END Static Sleep Submit Form Click Button css:#save Click Button css:#logout *** Keywords *** Init Session ${options}= Headless Chrome Init Testproject Driver chrome timeout=5000 job_name=TestProject Robot url=https://example.testproject.io/web/ desired_capabilities=${options} Close Session Close All Browsers Equals [Arguments] ${x} ${y} Should Be Equal As Strings ${x} ${y} Clear Fields Clear Element Text css:#name Clear Element Text css:#password Headless Chrome ${chrome_options} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver Call Method ${chrome_options} add_argument headless Call Method ${chrome_options} add_argument disable-gpu [Return] ${chrome_options} Base Login [Arguments] ${input_password} Press Keys css:#name ${EMAIL} Input Text css:#password ${input_password} ${password}= Get Value css:#password ${result}= Run Keyword And Return Status Equals ${password} ${CORRECT_PASSWORD} Run Keyword If "${result}" == "True" Run Keywords True ... ELSE Clear Fields Run Keywords True Click Button css:#login Sleep 3s Static Sleep Sleep 3s *** Variables *** ${EMAIL} [email protected] ${INCORRECT_PASSWORD} 67890 ${CORRECT_PASSWORD} 12345 ${INDEX} 0 ${CAPABILITIES} ${EMPTY.join(${_tmp})} @{INPUT_ELEMENTS} css:#address css:#email css:#phone @{INPUT_VALUES} Melbourne [email protected] 7521234545 @{_tmp} ... browserName: chrome, ... version: 86, ... name: RobotFramework Test
Visit our GitHub repository to learn more about this exciting new TestProject Library for Robot Framework β¨
Robot KDT Reports in the TestProject Cloud
Now, the Robot KDT reports in the cloud you’ve all been waiting for! β π Once you complete the local execution of your tests using the TestProject library for Robot, you will automatically receive your Robot KDT reports and screenshots directly in the TestProject reporting dashboard.
Below is an example of how the test reports look like. You can also download the test reports into a detailed PDF file! This is an example you can download directly from here to see for yourself!
For those of you who prefer watching tutorials β You should definitely watch this awesome webinar recordings presented by Ran Tzur and Antti Karjalainen β¨
π Get the Presentation Slides π
All of the Robot fans out there – Now’s the time to start exploring these awesome cloud KDT reports!
Share your thoughts in the comments below π€ππ
Very nice, i will try it.
Hi Ran Tzur,
I tried from python it worked very well,
When i tried from jython hitting import issues, what i am missing here:
C:\Users\bhagym>jython C:\jython2.7.2\Lib\site-packages\robot\run.py F:\Docs\Download\Webservices\Docs\Quiz\Robotic_Tests\MyRobotTestv1.robot
[ ERROR ] Error in file ‘F:\Docs\Download\Webservices\Docs\Quiz\Robotic_Tests\MyRobotTestv1.robot’ on line 2: Importing test library ‘TestProjectLibrary’ failed: ImportError: No module named TestProjectLibrary
Traceback (most recent call last):
None
PYTHONPATH:
C:\jython2.7.2\Lib\site-packages
C:\jython2.7.2\Lib
__classpath__
__pyclasspath__/
CLASSPATH:
C:\jython2.7.2\jython.jar
i can run this with java?
TestProjectLibrary missing lib.
Hello, we support only python at the moment.
We will check about adding support for Jython as well.