Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative Path for Imports #20

Closed
frodo23g opened this issue Oct 5, 2022 · 12 comments
Closed

Relative Path for Imports #20

frodo23g opened this issue Oct 5, 2022 · 12 comments

Comments

@frodo23g
Copy link

frodo23g commented Oct 5, 2022

Hello,

I missed some updates for this Plugin for Pycharm and I tried the new Version 0.0.9 from 0.0.3.

I don't know if it is possible to set this anwhere in the Settings, but now the Imports for Library's or Resource's are a little off from the older version.

I have created some Userlibraries in my Project and to import those I have to use relative Path to the Resource

Resource ../Resource/Test.robot

Now with the Version 0.0.9, my Test can't find the Recourse anymore in my IDE. I can use

Resource Test.robot, when it is a unique name, or
Resource Resource/Test.robot

When I execute the Test in my IDE it is working good, but when I want to execute it in a CLI it can't find the Recourse anymore because it wants the Relative Paths.

I hope it is an issue and not something I miss with my settings.

Best Regards and Thanks for this good Plugin :-)

@jnhyperion
Copy link
Owner

jnhyperion commented Oct 10, 2022

according to robot user guide: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#resource-files

the resource file is first searched relatively to the directory where the importing file is located.

plugin follows the same rule, please make sure your resource file path is correct.

for the execution issue: plugin is running robot command line under project root folder, and it's also the good practice for manual CLI execution.

@frodo23g
Copy link
Author

Hello,
that is good to know, and thanks for the link.
But I don't think, that its only an issue in my Settings where I have to set my module search path.
I can say, yes you are right, the Plugin works like that.
But Interesting is, that when I change between Versions from 0.0.5 to 0.0.6 and doesn't change anything in my Test and Resources Structure Relative Paths are not Found anymore.

My Testsuite looks like
*** Settings ***
Suite Setup open Tunnel to SauceLabs
Suite Teardown close Tunnel to SauceLabs
Test Setup open Page for Testing
Test Teardown closeClear BroswerSession
Library SeleniumLibrary
Resource ../Resources/Keywords/SauceLabs.robot
Resource ../Resources/Keywords/CommonWeb.robot

*** Variables ***
${searchField} id=search_form_input_homepage
${url} https://duckduckgo.com/

*** Test Cases ***
TC1
Go To ${url}
sleep 10s
Wait Until Element Is Visible ${searchField} #timeout=60s
Input Text ${searchField} This is Entered from Me
Click Element xpath=//input[@id='search_button_homepage']

I will try to change my CLI execution to run in project root folder.

@jnhyperion
Copy link
Owner

in version 0.0.6 there's a bugfix:

  • Incorrect import reference when there are multi python/resource files with the same name

perhaps you have multi kw with same name?

what's your project structure?

something like this?

root
├── Resources
│   └── Keywords
│       └── kw.robot
├── Suite
│   └── TestSuite.robot

@frodo23g
Copy link
Author

Yes, my project structure looks like that.

I will check on the naming of my resourcefiles, but at first glance, i dont see any duplicates.

My KW are not duplicated

@jnhyperion
Copy link
Owner

jnhyperion commented Oct 17, 2022

image

here's a simple example, I didn't see any problems.

@frodo23g
Copy link
Author

frodo23g commented Oct 18, 2022

I tried to test it on another Maschine and there I couldn't see the Issue eather...
I don't think it is a OS issue, because my other maschine was Linux and not Windows.

Maybe it is something in my Settings of Pycharm, that it can't find my Resources as a Relative Path.
I will try change some Project Interpreter settings.
When I look in the Interpreter Paths it doesn't show me my Folder where my Project is located. With Version 0.0.5 it can see my Resources with relative Paths, but not with Version 0.1.0, and adding the Path manually doesn't change my issue.

Thanks for your replies and maybe I will find something...

@wuqianxing
Copy link

image

here's a simple example, I didn't see any problems.

This example also has problems on my computer.
OS: windows 10 19044.2130
Python Version: Python 3.6.8
IntelliJ IDEA 2022.2.1 (Community Edition)
Build #IC-222.3739.54, built on August 16, 2022

@frodo23g
Copy link
Author

frodo23g commented Oct 19, 2022

image here's a simple example, I didn't see any problems.

This example also has problems on my computer. OS: windows 10 19044.2130 Python Version: Python 3.6.8 IntelliJ IDEA 2022.2.1 (Community Edition) Build #IC-222.3739.54, built on August 16, 2022

In Your Picture, it looks like that it is working. But on my Side it shows at the Imported Resource a yellow marker:

grafik

I have tried another windows 10 machine. Same issue with my initial Post here.
OS: windows 10
Python Version: Python 3.10.8
IntelliJ IDEA 2022.2.3 (Community Edition)

@jnhyperion
Copy link
Owner

confirmed, it's a bug only in windows

@heunck
Copy link

heunck commented Nov 10, 2022

Same issue occurs on my machine.

My OS details
Edition Windows 10 Pro
Version 21H2
OS build 19044.2130

@jnhyperion
Copy link
Owner

fixed in 0.1.2

@frodo23g
Copy link
Author

frodo23g commented Nov 11, 2022

It's working again with relatve Path's!
I've tested it on Windows 10 and on Linux.
Thanks for your work.

OS: windows 10
Python Version: Python 3.10.8
IntelliJ IDEA 2022.2.3 (Community Edition)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants