Reputation: 239
I have this code to execute on robot framework:
${result}= Execute JavaScript window.document.evaluate("//div[@id='priceBandTableForm:priceBandBox_panel']/div/ul/li[1]/text()", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
The result is this:
${result} = None
I have tested the javascript code on chrome console and it works.
Any ideas of what I'm doing wrong?
Upvotes: 0
Views: 1052
Reputation: 31
Use the execute javascript like mentioned below.
${textToCompare}= Execute JavaScript return document.evaluate('<Your Xpath here>', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent;
Upvotes: 0
Reputation: 239
I have resolved this by adding ".textContent" at the end, and "return" at the beginning.
${result}= Execute JavaScript return window.document.evaluate("//div[@id='priceBandTableForm:priceBandBox_panel']/div/ul/li[1]/text()", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent;
Upvotes: 2