RobotFramework with Python 3 and Page Object Pattern plus BDD

If you are a Python lover and need to automate your applications, just try RobotFramework with Python 3.

I have written a simple web test automation project that includes general things that you will need.

  • Keyword Driven (Gherkin style) Test cases.
  • Page Object Pattern in Python.
  • Selenium Webdriver.
  • Good Test reporting and logging.

There are lots of inbuilt libraries and support for API, Appium Mobile testing, Database testing, Desktop testing. Also, You should create your own custom library and import it in the Robot Framework.

You should get in love with CI/CD integration plugins and robot framework’s command line support. I should not say that there is no need for programming knowledge, but I believe that will be the easiest one for you. It is easier than Java+Cucumber. Less code with Python, less programming knowledge with Python, fewer extensibility problems with Robot Framework.

It is not magic, it’s Python.

Tested on:

  • Robot Framework 3.1.2 (Python 3.8.1 on win32)
  • Python 3.8.1
  • SeleniumLibrary 4.1.0

Required installations

  • Python 3 -> https://www.python.org/downloads/
  • pip install robotframework
  • pip install –upgrade robotframework-pageobjectlibrary
  • pip install –upgrade robotframework-seleniumlibrary
  • pip install webdrivermanager
  • webdrivermanager firefox chrome –linkpath /usr/local/bin
  • pip install -r requirements.txt

Behaviour Driven Development (BDD) in Gherkin

robotframework with BDD

Running Tests Commands

robot tests\HepsiburadaTest.robot

robot –variable BROWSER:Chrome tests\HepsiburadaTest.robot

robot –variable BROWSER:Firefox tests\HepsiburadaTest.robot

robotframework with page object pattern

robot framework with python 3

IntelliJ settings

Open (File-> project Structure -> Project Settings -> Project)

Select (Project SDK-> New -> Python SDK)

Select (Add Python Interpreter->System Interpreter-> OK/Apply)

OS System Environment Variables (for Windows)

Add the following lines to your PATH env. variable. You need to edit the username and version fields. Otherwise, you should get the following errors.

WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH.

WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH.

C:\Users\YOUR_USER_NAME\AppData\Local\Programs\Python\Python38 C:\Users\YOUR_USER_NAME\AppData\Local\Programs\Python\Python38\Scripts C:\Users\YOUR_USER_NAME\AppData\Local\salabs_\WebDriverManager\gecko\v0.26.0\geckodriver-v0.26.0-win64
C:\Users\YOUR_USER_NAME\AppData\Local\salabs_\WebDriverManager\chrome\79.0.3945.36\chromedriver_win32\

Extra Information/Libraries/Updates/Documentations/Tools

https://robotframework.org/

Repository of the project

https://github.com/swtestacademy/RobotFramework-Python3-SeleniumLibrary-WebTestSuite

Thanks.
Ozgur Kaya

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.