Robot Framework Automation Tests with Playwright Library for Browser Automation
In this blogpost, we will discuss how to run the Robot Framework automation tests using Playwright Library on Visual Studio code IDE.
The Robot Framework team call the Playwright Library as "Browser". This is similar to Selenium Library.
First things first, I will put this blogpost in two simple points.
1. Set up
2. Test Automation framework
1. Set Up : Do the following installations on your Mac.
- Install Homebrew : Go to the page Homebrew for reference. Run the command below on your terminal to install Homebrew:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Node: Run the command "brew install node" on your terminal
- Install Python3 : Go to Python3-Download
Check your path of python3 : Run the command "which -a python3"
Note down this path:
/Library/Frameworks/Python.framework/Versions/3.13/bin/python3
- Install Browser library from PyPi with pip: Run the command on your terminal pip3 install robotframework-browser
- Initialize the Browser library: Run the command on your terminal rfbrowser init
- Download Visual studio Code: Go to Visual Studio Code Download
Open your Visual studio code, Go to market place and install the plugin "Robot Framework Language Server" and install this plugin
Go to settings as shown below
Install the plugin "Robocorp code" as shown below
We can avoid setting up the Project interpreter and intellibot plugin by using VS Code compared to Pycharm IDE.
Drivers and browsers will come as a bundle when you install playwright powered library "Browser".
On the other hand, in Browser library there are 3 layers: Browser, Context, Page which is the same like in our typical Playwright.
Documentation: For Official documentation, Please visit
2. Test Automation framework: A basic boilerplate code using Page Object Design framework is created for this post and the folder structure, page objects, pages, test and test report are shown below.
The Folder structure looks like this
Page Objects: The locators used for the test
*** Settings ***
Documentation Page Objects for Login Page
*** Variables ***
${USERNAME} data-test=username
${PASSWORD} data-test=password
${LOGIN_BUTTON} data-test=login-button
${BOT_IMAGE} css=.bot_column
Pages : The individual web pages used for the test
Test : The test scenario description and test steps mentioned for the test. Documentation giving the overview of the test, Libraries and Resources imported.
The Test Cases section are named with keywords as PageName.FunctionName for example "LoginPage.TypeText"
Test Run : Run the command "robot -d Report Tests/*.robot " on your terminal
Test Report: From your Report Folder 'Report/report.html'
Test Output:
For test code reference, Please see GitHub Repo: GitHub Repo
Test Run : Run the command "robot -d Report Tests/*.robot " on your terminal
Test Output:
For test code reference, Please see GitHub Repo: GitHub Repo
Conclusion:
With Browser Library:
1. No Need to Download browser drivers.
2. Browser Library is pretty faster in test execution when compared to Selenium Library.
3. Browser Library powered by Playwright is reliable, visible and faster.
4. Supports chromium, firefox and safari(webkit) browsers.
5. Good shadow DOM support.
Happy Automation Testing Guys :)!