Closed kkotenko closed 4 months ago
could u pls provide the error example? As I test it still works with AS anyway
So this is actually more complicated than I expected, my apologies for not realizing it earlier. It seems to be related to how deeply nested the actual library is.
Here are two files, identical apart from AS/WITH NAME. You will need rpaframework~=28.3.0
for this.
*** Settings ***
Library String AS Alias
Library Browser.Selenium AS Selenium # https://rpaframework.org/libraries/browser_selenium/index.html
Library RPA.Excel.Files AS ExcelFiles # https://rpaframework.org/libraries/excel_files/index.html
Library RPA.Excel.Application AS ExcelApp # https://rpaframework.org/libraries/excel_application/index.html
*** Test Cases ***
Depth 1
[Tags] robot:continue-on-failure
# I expect this to not pass syntax check:
String.Generate random string
# I expect this to pass syntax check:
Alias.Generate random string
Depth 3
[Tags] robot:continue-on-failure
# I expect this to not pass syntax check:
Files.Append rows to worksheet
# I expect this to pass syntax check:
ExcelFiles.Append rows to worksheet
Import library with wrong base name
[Tags] robot:continue-on-failure
# The actual name of the Library is RPA.Browser.Selenium, but we imported it with Browser.Selenium and renamed it
# this is shown as valid code, but fails - might be a bug with Robot Framework
Selenium.Get browser capabilities
# I expect this to not pass syntax check:
Browser.Selenium.Get browser capabilities
# I am actually not sure which way this should work
RPA.Browser.Selenium.Get browser capabilities
*** Settings ***
Library String WITH NAME Alias
Library Browser.Selenium WITH NAME Selenium # https://rpaframework.org/libraries/browser_selenium/index.html
Library RPA.Excel.Files WITH NAME ExcelFiles # https://rpaframework.org/libraries/excel_files/index.html
Library RPA.Excel.Application WITH NAME ExcelApp # https://rpaframework.org/libraries/excel_application/index.html
*** Test Cases ***
Depth 1
[Tags] robot:continue-on-failure
# I expect this to not pass syntax check:
String.Generate random string
# I expect this to pass syntax check:
Alias.Generate random string
Depth 3
[Tags] robot:continue-on-failure
# I expect this to not pass syntax check:
Files.Append rows to worksheet
# I expect this to pass syntax check:
ExcelFiles.Append rows to worksheet
Import library with wrong base name
[Tags] robot:continue-on-failure
# The actual name of the Library is RPA.Browser.Selenium, but we imported it with Browser.Selenium and renamed it
# this is shown as valid code, but fails - might be a bug with Robot Framework
Selenium.Get browser capabilities
# I expect this to not pass syntax check:
Browser.Selenium.Get browser capabilities
# I am actually not sure which way this should work
RPA.Browser.Selenium.Get browser capabilities
The syntax highlight behaves differently in the two files.
# this is shown as valid code, but fails - might be a bug with Robot Framework. Selenium.Get browser capabilities
-> you need to import RPA.Browser.Selenium to make it work. The plugin find out the lib but robot can not
Currently, the plugin regards a reference to a library import with
LibraryName AS Library
as an error (ie. Library.Keyword will produce a syntax error). However, AS is now the preferred way since RF 6.0, see https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#setting-custom-name-to-library.As far as I understand the code, my changes fix that. Please test it, I am not sure how to actually pack this into a plugin file I could test with.