mtrubs / intellibot

IntelliJ/PyCharm plugin for Robot Automation Framework
https://github.com/millennialmedia/intellibot/wiki
MIT License
158 stars 109 forks source link

Support for resolving paths that are given as Robot variables #117

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi,

It would be great if plugin could resolve paths to resources that are given as Robot variable. For instance: Now plugin is working good once we put the absolute path to resource eg.

Resources /home/test/lib/keywords.robot

Keywords resolving works in such case.

Once I put some Robot variable in variables section for instance in the same testfile eg.

${RESOURCE} /home/test/lib/

And then:

Resource ${RESOURCE}keywords.robot

Keywords resolving doesn't work in such case. There is message from PyCharm: "Import file not found"

twbecker commented 8 years ago

+1 None of current Robot plugins currently support this. Even if all the plugin did was to read in a robotvariables.py file it would be great.

lmc182 commented 8 years ago

I'm having the same problem. I'm trying to use the built in global robot framework variable ${EXECDIR}, like this: Resource ${EXECDIR}/Sites/Resources/CST.robot

The execution of the scripts works without errors, but every line in my test cases section says "Keyword definition not found" and all are underlined with red, so I've lost the ability to use ctrl + click to navigation through the scripts.

The only way to make the red lines go away is to change the resources so that they use the full execution path: Resource C:/dev/scripts/robotfw/Sites/Resources/CST.robot

This work around isn't great because everyone on the team seems to be using a different execution path. It would be nice if we could use the global execution directory variable ${EXECDIR} that comes with robot framework.

shamaho commented 8 years ago

+1 I think almost everyone uses a variable to point to resource location or at least to some part of that path, thus keyword navigation becomes impossible for anyone that applies this good practice.

aleblanc39 commented 8 years ago

In case anyone is interested, I made some modifications to the plugin code to partly do what is being discussed here. More specifically, in the case of the example above, when a variable named ${RESOURCE} is encountered in a path the new code will substitute the content of a environment variable named ROBOT_RESOURCE. This is a quick fix that makes intellibot much more useful in our setup, where we have a lot of files with a few variable of the same name with the same value. So if you have lots of variables, or variables with the same name having different values in different files then this won't do much for you.

It involved changes in only one file. If someone wants it I can share the resulting jar as well as the modified source file.

mtrubs commented 8 years ago

If you want to make a pull request I would be happy to take and build off of it. I recently added some of the built in vars and I imagine that can help there too.

aleblanc39 commented 8 years ago

I'll test your latest. It's likely that all the functionality I added is already there. If not then I'll make the pull request.

mtrubs commented 8 years ago

So I did add a good deal of resolution for variables. I think getting to the context though is something yet to be added. For example resource ${CUR_DIR}/a/sample.robot will still have issues because CUR_DIR has no context to /user/you/project/src (yet).

shamaho commented 8 years ago

How do I install this latest version ? I downloaded the ZIP file, installed the plugin but upon restarting IntelliJ 15.0.3 Coomunity Ed., I got:

"Cannot load project: com.intellij.ide.plugins.PluginManager$StartupAbortedException: com.intellij.diagnostic.PluginException: com.millennialmedia.intellibot.psi.RobotPsiManager PluginClassLoader[com.millennialmedia.intellibot, 0.9.143.381] [Plugin: com.millennialmedia.intellibot]"

What am I missing ?

mtrubs commented 8 years ago

The latest artifact that I have generated is the jar file in the master branch (https://github.com/millennialmedia/intellibot/raw/master/intellibot.jar). If you build it yourself you have to make sure that that python.jar is of scope provided in the module dependency settings. Then when you build the plugin you should get a jar artifact as opposed to a zip. I do not know what zip you mean otherwise.

smaspe commented 8 years ago

Same issue here. We defined the same keywords in different PO models for different targets and have a variable for pointing to the right resource directory. So we could really use the support for variables in resource path.

(I tried the master jar build, it does not support it).

I would do the PR if that can help, but I have no idea where to start.

(I use it in PyCharm 2016.1.4, if that's of any use)

mtaylorSF commented 7 years ago

Is there any current workaround for this addition?

jourdanbennett commented 7 years ago

I am having the same issues. Is there an update for this? work around or solution? Thanks

awesomeamyg commented 7 years ago

+1 I'm working on a project that uses a ${root_directory} variable in all its files to provide an absolute path. When calling pybot, we use -v to define the root_directory variable. Is there any way to add variables to Intellibot like the -v for pybot?

tracymazelin commented 7 years ago

+1 same issue for ${EXECDIR}. Would love to see this resolved.

TomskDiver commented 7 years ago

+1

barbara-lea commented 5 years ago

+1

rapidroamer commented 5 years ago

+1

rapidroamer commented 5 years ago

I think I've found a workaround / solution folks @lmc182 Resources /models/google_search/HomePage.robot ##doesn't resolve Resources models/google_search/HomePage.robot ##resolves perfectly.

cnaidu3 commented 5 years ago

I am having a similar issue...any solution for this??