0

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?

3 Answers 3

2

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;
Sign up to request clarification or add additional context in comments.

Comments

1

You probably forgot to add return before the JS ?

Comments

0

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;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.