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):

… save as C:\Program Files (x86)\robotframework-2.9\src\bin\
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:

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.
    (the old site)

    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.