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
When Robot Framework imports a library, it tries to import just the class named the same as the .py file - as in your case, the class OrderList
in the OrderList.py
file. And it doesn't import any other classes - check the documentation for more details.
The easiest option would be to have the class you are going to use renamed, to the same name as the file.
If that's not applicable - and looks like your intent is to use more than one class, you could have the file in your PYTHONPATH (like, physically moving the file to a dir in it, or extend it to include the module's one) and import the classes separately as OrderList.Ordertable
.
Another would be to solve it on the python side - put each class in a module of their own, each importing the one with the base class.
The first is ops nightmare, the second - design & maintenance; your choice :).
Here is an example about how to import a class as a library and not the whole python file:
tests
there is a test.robot and an OrderList.py file.OrderList.py:
class OrderList():
pass
class Ordertable(OrderList):
def click_order(self):
print('foo')
test.robot:
*** Settings ***
Library OrderList.Ordertable
*** Test Cases ***
AA
click order
Launch it with the following command from the parent folder of the tests
folder: robot --pythonpath .\tests\ --test AA .\tests\test.robot
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