Get attribute value and set as variable

110 Views Asked by At

I 'm new with Robot Framework. I want to get an value and set it as variable. This value is an order amount and will be different everytime. I succeed to create this xpath with the same amount everytime, but how to define this in a flexible way? What should I define in my xpath instead of the hard coded amount 38,66?

<div data-bind="html: HtmlEntityEncoder.htmlDecode(text())" style="">€ 38,66</div>

This is my xpath:

${Order_Amount_Checkout_Page}=  Get Text  //div[1]/div[@innertext='€ 38,66']
2

There are 2 best solutions below

0
Helio On BEST ANSWER

You can use variables in expressions. or example:

${my_value}=  Set Variable    € 38,66
${Order_Amount_Checkout_Page}=  Get Text  //div[1]/div[@innertext='${my_value}']
0
Pramesh On

You could do something like:

${Order_Amount_Checkout_Page}=  Get Text    //div[1]/div

Idea is to get the absolute path of the WebElement and Get Text from this this WebElement.