Hwo to write tests for RobotFramework code to run in circleci?

I discovered RobotFramework recently.

As a web developer using python and django, I am used to write unit tests or integration tests that are run in ci/cd providers like circleci.

How and what kind of tests are best to write for RobotFramework code? And how to make them runnable in places like circleci?

let’s assume there are two kinds of scenarios:

  1. a RPA that involves web browser (selenium)
  2. a RPA that involves a macOS Desktop app (let say turning on the Maps.app)

Running in CI/CD isn’t really different from running (Python) unit tests; Robot Framework is a Python package, just like e.g. pytest. So it’s just a python -m robot <args> instead of e.g. python -m pytest <args>.

For web automation, you can use SeleniumLibrary or Browser. The former is Selenium-based, the latter is PlayWright-based. I’m not too familiar with macOS Desktop app automation, others may be able to suggest libraries for that.

So you’re suggesting to use pytest to test robot code?

The reason i stated the scenarios is because i assume the good practice for each scneario may be different.

For e.g.

  1. for the web, mock the external webpage the RPA will likely need to itneract with
  2. for the macOS desktop, maybe cannot mock but can spin up macOS vm on circleci to test directly.

I am not asking about what robotframework libraries to use exactly for each scenario. more like the test practices

No, I’m not suggesting using pytest to test Robot Framework suites, I’m indicating that running Robot Framework suites in a CI/CD is no different from running pytest in CI/CD. The commands are virtually the same.

When it comes to good test practices, there’s many layers to it. For example web testing:

  • First, there should be unit tests on the frontend code (most likely JS/TS). Those generally run with many mocks / stubs.
  • Then there should be functional level tests; going through the application flows. This could be ran on a version of the site that “talks to” a mocked backend.
  • But then there’s integration; you’ll want to verify that the functional tests also work on the site that’s talking to an actual backend.

For (native) app testing, you’ll indeed need to have some host, VM or container with the target application installed. In addition, you’d install Python and the desired packages (RF and the libraries of choice) and run the tests.

i am not sure if i explain my original question that may have mislead you or i mis understand this point.

I am expecting to write RPA related code using RobotFramework. So the code in question is likely to be RobotFramework syntax.

I don’t expect to write any frontend code like JS/TS.

I foresee the bulk of my RPA code to fall into two categories:

  1. interacting with external webpages via browser
  2. interacting with macOS desktop apps

Hence my purpose is to ask (directionally) how to write tests for CI/CD purposes for RPA code running in providers like CircleCI.

I do not expect to write RobotFramework code as test suites to test other code such as JS/TS, etc

Did i cause any misunderstanding by accident? or i misunderstood your response?

You don’t write tests to run on CI/CD, you write tests that work fine on your local machine, and then configure your CI/CD to have the conditions to run them.
For example, if using SeleniumLibrary, then the CI/CD machine must have the proper webdriver, and the browser installed. If using headlessbrowser, then there is no need to have a GUI environment.

When testing a macOS app, then you need to have a real machine as a node of your CI/CD. I do this with Jenkins, where my macOS node is connected with the java client, and has the testing automation user always logged in. Of course, your setup may have to be different.

1 Like

Thank you, Helio. YOur answer really makes me feel a lot closer to what i am looking for.

Just two followup questions,

  1. if initially i wrote a code that uses seleniumlibrary and it works, i guess it depends whether the same logic or code can be kept when switching to headless browser yes?
  2. sounds like you manage to use RobotFramework on macOS app. what ci/cd provider did you go with in that setup?

Yes, it is straight forward. If you defined a variable for your browser just change it to the headless corresponding name. For example robot -v browser:headlesschrome ...
You only may need to adjust timings with Wait ... keywords. If you test first in local system, it should behave the same in CI/CD system.

This is in-house solution, real hardware macMini as a node of Jenkins. But use it for testing with Safari and Appium (Android and iPhone), macOS apps never tried because not needed (but would go for Sikuli as first try).

RaiMan/SikuliX1: SikuliX version 2.0.0+ (2019+) (github.com)

This one?

Yes, that is the current maintained version (and it is on GitHub now :wink: , I did not know).
But that is the original framework, which I recommend to try and use, before using the Robot Framework wrapper, here.

1 Like