Inner nested class access from robot framework

后端 未结 2 843
一生所求
一生所求 2021-01-28 19:23

Robot - 3.1.1 Python - 3.7.3

I wanted to access method that are written in nested inner class from robot framework.

Robot:

*** S         


        
2条回答
  •  不要未来只要你来
    2021-01-28 19:55

    Here is an example about how to import a class as a library and not the whole python file:

    1. In a folder named tests there is a test.robot and an OrderList.py file.
    2. OrderList.py:

      class OrderList():
                 pass
      
      class Ordertable(OrderList):
             def click_order(self):
                  print('foo')
      
    3. test.robot:

      *** Settings ***
      Library        OrderList.Ordertable
      
      *** Test Cases ***
      AA
          click order
      
    4. Launch it with the following command from the parent folder of the tests folder: robot --pythonpath .\tests\ --test AA .\tests\test.robot

    5. Result:

      PS prompt> robot --pythonpath .\tests\ --test AA .\tests\test.robot
      ==============================================================================
      Test
      ==============================================================================
      AA                                                                    | PASS |
      ------------------------------------------------------------------------------
      Test                                                                  | PASS |
      1 critical test, 1 passed, 0 failed
      1 test total, 1 passed, 0 failed
      ==============================================================================
      Output:  C:\Users\myuser\output.xml
      Log:     C:\Users\myuser\log.html
      Report:  C:\Users\myuser\report.html
      

提交回复
热议问题