Shakti2689
(Shakti Srivastava)
1
Hello, Good Morning!!
I wrote “Evaluate JavaScript window.function()” in my robot test case with browser library but it is throwing below error
“Error: locator.evaluate: Unexpected token “function(” while parsing css selector “window.function()”. Did you mean to CSS.escape it?
Call log:
- waiting for window.function()”
However when I manually ran this function on my browser console, it worked as expected. ie. function()
Could you please help me, how can I call this function in my test case
Hi Shakti,
I suspect your problem is not having a selector, If I’m right, based on the Evaluate JavaScript docs, you could try either:
Evaluate JavaScript ${None} window.function()
or
Evaluate JavaScript function=window.function()
Dave.
1 Like
Gerwin
(Gerwin Laagland)
3
An implementation that I’ve been using for an angular solution:
${value) Evaluate Javascript ${None} () => window.getAllAngularTestabilities && window.getAllAngularTestabilities().every(t ->t.isStable())
Dave is right that the selector might be your problem. It’s a mandatory argument. But can be filled with ${None}.
2 Likes
Shakti2689
(Shakti Srivastava)
4
Thank you Dave!!
“Evaluate JavaScript ${None} window.function()” worked !!
1 Like
Shakti2689
(Shakti Srivastava)
5
Thanks for your input. Much appreciated !!
1 Like