lte2000 / intellibot

IntelliJ/PyCharm plugin for Robot Automation Framework
https://github.com/lte2000/intellibot
MIT License
90 stars 27 forks source link

Library Keywords and other variables not recognized if nested in other files #1

Closed zastress closed 4 years ago

zastress commented 4 years ago

I have 2 resource files for robot framework, called resource1.robot and resource2.robot. Inside resource1.robot I have resource2 declared as resource. Inside resource2 I declared SeleniumLibrary inside the *** Settings *** section. By default, if I try to call a SeleniumLibrary keyword inside the resource1 file, intellibot should be able to recognize it.

The problem: keywords are not recognized.

Solution: Declare SeleniumLibrary inside the *** Settings *** section of resource1 file also.

This is a basic example but it also applies when you have a test that uses a certain resource file and that file is linked with another one that has the library declared.

Same thing for variables.

To be noted that the old intellibot plugin has no problem with this.

To better understand the issue, here is the example

resource1.robot file:

*** Settings ***
Resource        resource2.robot

*** Keywords ***
Open To Main Page
    Open Browser        example.com

resource2.robot file:

*** Settings ***
Library         SeleniumLibrary

So, in this example, the Open Browser keyword called inside resource1 file is not recognized.

Feel free to ask more details if this is not clear.

I confirm that this issue is also present on the latest version, the dev-0.10.143.384.

Thanks for your help.

lte2000 commented 4 years ago

In Settings->Languages & Frameworks->Robot Options, The original Intellibot has an option "Allow Transitive Imports", can be ON/OFF. Now it is extened to "Max Transitive Imports Depth", can set to be 0~99, i.e., how many "Library/Resource" is needed to reach that keyword. That is because I work on a large project, there're many resource files cross-referenced deeply. If it is set to ON, the startup time is very long. If it set to OFF fully, then it is very inconvenient. The new design will be a trade-off setting.

In your case, if "Max Transitive Imports Depth" is 0, then in resource1.robot, it will not resolve keywords in resource2.robot. if "Max Transitive Imports Depth" is 1 (default), then in resource1.robot, it will resolve keywords in resource2.robot but will not resolve keywords in SeleniumLibrary (same behaviour as original "Allow Transitive Imports" = OFF). if "Max Transitive Imports Depth" is 2, then in resource1.robot, it will resolve keywords defined in resource2.robot and SeleniumLibrary. If you don't care the performance, you can it to 99 (like original "Allow Transitive Imports" = ON).

zastress commented 4 years ago

Set it to 3 and works just fine. Thanks