I’m writing some RF tests where some of the keywords are implemented in a Robot Framework Remote Library. I’m having trouble getting VSCode to recognize those keywords for code completion/IntelliSense.
Both the .robot
test suites and the python library is in the same git repo. At runtime, I copy the remote library to the target under test and execute it there and then
Import Library Remote http://${TARGET}:8270
The tests successfully use the keywords defined in remote library.
VSCode can do code completion for “normal” keywords implemented in .robot
files, but not for the keywords implemented in the remote library.
I’ve tried using d-biehl.robotcode
and robocorp.robotframework-lsp
as the language servers. I also added the path to the python file where the remote library is implemented to the python path as follows, but that didn’t help either:
"robotcode.robot.pythonPath": [
"./resources/remote/ROSRobotFrameworkRemoteLibrary.py"
]
Is it possible to get this working? I’m thinking it might not just be a python path problem, but also an issue with the VSCode extension not realizing that the keywords are implemented in that file since they are not imported at the top of the suite as usual, but will get imported with the Import Library
keyword at runtime.
The code looks something like this:
./tests/MyTests.robot
:
*** Settings ***
Resource ../resources/Remote.resource
Suite Setup Setup Suite
*** Test Cases ***
Hello Robot
Robot should say hello # implemented in the remote library. Runs successfully, but VSCode underlines in red
*** Keywords ***
Setup Suite
Remote.Setup remote
./resources/Remote.resource
:
*** Keywords ***
Copy files to remote
# scp ROSRobotFrameworkRemoteLibrary.py to the remote
Start remote server
# execute python3 /tmp/robot-framework/ROSRobotFrameworkRemoteLibrary.py on the remote machine
Setup remote
Copy files to remote
Start remote server
Import Library Remote http://${TARGET}:8270
Remote library should be available
./resources/ROSRobotFrameworkRemoteLibrary.py
:
from robotremoteserver import RobotRemoteServer
class ROSRFRemoteLibrary:
def __init__(self) -> None:
pass
def remote_library_should_be_available(self):
print("Remote library is available")
def robot_should_say_hello(self):
print("Hello from remote library")