robotframework / RIDE

Test data editor for Robot Framework
Apache License 2.0
964 stars 379 forks source link

Keyword completion should be available also for libraries that are imported in a resource file #487

Closed robotframework-ride closed 9 years ago

robotframework-ride commented 9 years ago

Originally submitted to Google Code by gerhard.heil on 17 Jun 2010

I would like to have the feature keyword completion / keyword description in all my test suites and for all libraries that I use. Currently it is only available if the library import is done in the setting table of the same test suite file.

As I have many test suites and init.html files that use a set of libraries, I prefer importing these libraries in the global resource file, instead of importing all libraries in every new test suite again. But then the keyword completion is not available.

Used RIDE version: 0.23

robotframework-ride commented 9 years ago

Originally submitted to Google Code by @yanne on 21 Jun 2010

This should be possible even now. The problem is that if there are problems in importing a particular library, the error is just ignored so it is hard to debug why the importing fails.

robotframework-ride commented 9 years ago

Originally submitted to Google Code by picoge... on 5 Jul 2010

Janne, Are you talking about the Auto imports mechanism, described here: https://code.google.com/p/robotframework-ride/wiki/Settings

I usually import ${RESOURCES}/myresource.html, where ${RESOURCES} gets set to a separate directory which I use for resources. I normally do not get keyword colorization/completion but I found that the auto imports works to solve that.

Wouldn't it be nice if we could specify an auto imports per project/directory?

robotframework-ride commented 9 years ago

Originally submitted to Google Code by @yanne on 9 Aug 2010

No, I am not talking about the auto imports.

When RIDE currently loads the data, all resource imports are gone through and if the corresponding resource files are found, the library imports are processed too.

Gerhard, are you able to create a simple example that demonstrates the situation where locating resource files fails?

Does the global resource file get opened in RIDE?

robotframework-ride commented 9 years ago

Originally submitted to Google Code by gerhard.heil on 11 Aug 2010

I have a common resource file in which the library imports are contained, so I don´t need to repeat the imports in every new test suite.

In my former tests suites I had imported the common resource file as relative path. Robot Framework itself could see this file, so the tests worked. But RIDE did see it. When I opened a test suite (directory), the resource file was not opened and RIDE did not show the keyword completion for the non-standard libraries.

Ok, RIDE is able to handle relative path also, but of course only if it is started from the current directory where the relative path works (i.e. if it is started from the same directory as the test runs).

After changing the start directory in RIDE properties, also import resource file by relative path works: Open Directory automatically also opens the resource file, and keyword completion is also fine :-)

robotframework-ride commented 9 years ago

Originally submitted to Google Code by picoge... on 12 Aug 2010

I guess Gerhard and I are having very similar problems. Because I use a variable file to set my ${RESOURCES} variable. Contents of my variable file: _dirname= os.path.dirname(file) RESOURCES= os.path.abspath(os.path.join(_dirname, '../../ResourceFiles'))

Since Ride does not look at the contents of variable files, it doesn't look up ${RESOURCES}/myresource.html and I don't get any keyword completion (or pydocs) for the libraries imported in my resource file.

Using auto imports is pretty ugly solution for me. Is a better solution possible?

robotframework-ride commented 9 years ago

Originally submitted to Google Code by @yanne on 5 Sep 2010

Actually, reading variables from variable files when resolving resources should be supported already. We'll investigate whether there's a bug hiding in the implementation.

robotframework-ride commented 9 years ago

Originally submitted to Google Code by @jussimalinen on 6 Sep 2010

I am unable to reproduce this. RIDE does handle the variable files just fine in my tests.

I created a variable file that defines a variable ${my var} and then imported this variable file in a resource file and imported that resource file to a test suite file. If I understood correctly this is similar to your setup Gerhard?

When editing test cases in that test suite file, Ride finds the variable ${my var} in keyword completion.

There must be something more complicated going on if you both have problems with variable files and Ride. Could you try to produce a simple example that demonstrates the problem and upload the files here?

robotframework-ride commented 9 years ago

Originally submitted to Google Code by gerhard.heil on 6 Sep 2010

The error was on my side, RIDE handles keyword completion correctly.

My situation was this (as roughly explained in comment 4): All my test suites import a common resource file; this common resource file imports the libraries (I do not have a variable file). My directory structure is this:

D:\Robot contains all Robot related files. From this directory, I start the test runs D:\Robot\TestSuites contains the common resource file "Resources.html" and some more files D:\Robot\TestSuites\fmagent contains all test suites for component fmagent D:\Robot\TestSuites\logangent contains all test suites for component logagent

The error was to import the resource file by relative path: Resource | ./TestSuites/Resources.html Robot could see this file, but RIDE is started from another current directory and could not follow this relative path. So also the libraries that are imported in the rsource file were visible to Robot bit not to RIDE. Since I import the common resource file by absolute path: Resource | D:/Robot/TestSuites/Resources.html bothe Robot and RIDE see the resource file and the libraries, keyword completion is correct.

Best regards Gerhard

robotframework-ride commented 9 years ago

Originally submitted to Google Code by @jussimalinen on 6 Sep 2010

Okay, thank you for clearing this Gerhard and glad to her your issue was solved!

Picogeyer: How do you import your variable file? Maybe there is also somekind of a path issue and the variable file does not get imported in RIDE because of that.

Right now system does not show any error message if library file is not found.

robotframework-ride commented 9 years ago

Originally submitted to Google Code by picoge... on 6 Sep 2010

In my setting table, I just have: Suite Setup Suite Setup
Variables vars.py

And then in the 'Suite setup' keyword, I do: Suite Setup Set Global Variable ${RESOURCES}

Then in lower level directories (suites), I do: Resource ${RESOURCES}/common.html

This all seems to work when I run it (pybot) but I never get any syntax highlighting for the libraries that I import in common.html

If it would help I can try extract a barebones example from my current work.

robotframework-ride commented 9 years ago

Originally submitted to Google Code by @jussimalinen on 6 Sep 2010

Okay, I was able to reproduce your problem picogeyer. There are two issues here:

1) Variables from variable files are not available when parsing resource imports. This is a bug in the system and will be fixed in next release.

2) 'Set Global Variable' is not handled by RIDE. There is not much we can do about this in the near future. RIDE does not handle Set Variable - type keywords. Also it does not handle variables that are set as return values from keywords. (In other words, RIDE does not actually run the keywords.)

In future we are planning to add an option to set variables to RIDE from command prompt (issue 78). Before that you could try for example these workarounds:

a) move your resource file to a path relative to your test suite files and import it using a relative path without a variable from a variable file.

b) once we get variables from variable files to work in resource imports, you could import your variable file in every suite where you import your resource file. (This instead of using Set Global Variable)

robotframework-ride commented 9 years ago

Originally submitted to Google Code by @jussimalinen on 6 Sep 2010

I created a new issue about the error in handling variable files in resource imports. ( issue 515 )

As for the Set Global Variable, we can not do anything about it unless some major changes are done to the way RIDE handles keywords. Therefore I will close this issue as WontFix for the time being.

robotframework-ride commented 9 years ago

Originally submitted to Google Code by picoge... on 6 Sep 2010

Thanks for your effort and for the workarounds. I'll monitor the new issue for progress.