Situation description:
I’m working on a project in UiPath where I want to inject JavaScript into a web page to retrieve specific information. The workflow uses the Inject JS Script activity, where the goal is to retrieve the text of the last element in a list (with a specific CSS class) and store it in a UiPath variable called description.
Problem:
When executing my JavaScript code I keep getting a SyntaxError. Initially I got the error message Unexpected token 'const', after which I tried to replace const with var. However, this resulted in a new error message: Unexpected token 'var'. It appears that the JavaScript code I am trying to execute is not being interpreted correctly by the UiPath environment. This suggests that there is a limitation in how the JavaScript code is handled by UiPath, possibly due to the version of the browser I am using or the syntax I am using.
What I tried:
- Changing from
consttovar: This led to a new error message. - Minimize the code: I tried simplifying the code to see where the problem lies, but the error still occurs.
- Function structure check: I made sure the JavaScript code was properly embedded in a function, but that didn’t solve the problem.
- Using older JavaScript syntax: Despite avoiding modern JavaScript syntax, I continue to receive the same error.
Thanks in advance for the help!