Use .NET libraries in Robot Framework

With Robot Framework on IronPython (Install Robot Framework with IronPython on Windows) you still implement the keywords in Python, but you can seamlessly access the wealth of .NET-libraries.

An example is worth a thousand words; so find an example how to use System.IO.File from .NET to create a file:


1.) IronPython (Python on .NET) file:

import System

class FileManager:

    def create_file(self, fileName):

        System.IO.File.Create(fileName)

… save as C:\Program Files (x86)\robotframework-2.9\src\bin\FileManager.py

2.) Robot Framework file:

*** Settings ***
Library    FileManager

*** Test Cases ***
My Test

    Create File    fantastic.txt

… save as C:\Program Files (x86)\robotframework-2.9\src\bin\ExampleTestCase.txt

The Keyword „Create File“ in this .txt is automaically matched to the create_file method from the Python file. The underscore is automatically „translated“ to a space.

3.) Execute in cmd:

cd C:\Program Files (x86)\robotframework-2.9\src\bin
ipybot ExampleTestCase.txt

Finished! Find fantactic.txt in C:\Program Files (x86)\robotframework-2.9\src\bin.

For more information on Robot Framework read: http://it-kosmopolit.de/blog/2015/09/27/strategic-link-collection-of-robot-framework/