I've been utilizing robot framework on a java/javascript page, attempting to scroll to a locator for verification of its text value. Although I found a solution in this QA that matches my issue, it throws an exception when executed.
Unable to scroll down the web page using the Robot Framework
Here is the locator I'm trying to scroll to:
${CLAIMS} xpath=//*[@id="generalAndIncidents:relatedAlertsPanel:idPreviousClaimsList"]
This is the keyword I'm using for scrolling (it takes one argument for the locator variable):
Scroll To Element
[Arguments] ${scroll_to_element}
Sleep 1s
Execute JavaScript window.document.evaluate("${scroll_to_element}", document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.scrollIntoView(true);
Sleep 1s
However, upon execution, I am encountering the following exception:
20:36:17.376 INFO Executing JavaScript:
window.document.evaluate("xpath=//*[@id="generalAndIncidents:relatedAlertsPanel:idPreviousClaimsList"]", document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.scrollIntoView(true);
Without any arguments.
20:36:17.758 FAIL JavascriptException: Message: javascript error: missing ) after argument list
(Session info: MicrosoftEdge=86.0.622.69)
I have also referred to this page for guidance on the javascript code snippet:
https://developer.mozilla.org/en-US/docs/Web/API/Document/evaluate
If you could provide me with some advice on how to start debugging, or if there are any issues in what I am doing, I would greatly appreciate it. Could it be related to missing escapes?
Thank you very much!
Update#1: Is this possibly linked to the namespace resolver?
Update#2:
Scroll To Element
[Arguments] ${scroll_to_element}
${x} = Get Horizontal Position ${scroll_to_element}
${y} = Get Vertical Position ${scroll_to_element}
Execute Javascript window.scrollTo(${x}, ${y})
Scroll Loop Click
[Arguments] ${locator}
FOR ${index} IN RANGE 1 10
Sleep 0.5s
${isElementVisible} = Run Keyword and Return Status Click Element ${locator}
Run Keyword If '${isElementVisible}'!='True' Wait Until Keyword Succeeds 6s 2s Scroll To Element ${locator}
Log ${isElementVisible}
Exit For Loop If '${isElementVisible}'=='True'
END
Wait Until Element is Visible ${locator}