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: https://it-kosmopolit.de/strategic-link-collection-of-robot-framework/

2 Gedanken zu „Use .NET libraries in Robot Framework“

  1. FYI, for those that prefer to code more natively in .NET via C# or VB.NET, etc. you can do that with Robot Framework (RF) via the remote library approach. There’s already generic servers that help you get started and make things easy to integrate with RF. Then you can run RF as pure Python without having to bother with IronPython.
    NRobotRemote
    https://github.com/claytonneal/nrobotremote
    (the old site) https://code.google.com/p/nrobotremote/
    SharpRobotRemoteServer
    https://code.google.com/p/sharprobotremoteserver/

    1. Hi David,
      that’s interesting news, I’ll try that, when I have to dive deeper into that topic.
      Yours Michael

Kommentare sind geschlossen.