Search code examples
selenium-webdriverxpathappiumrobotframeworkgetvalue

Get attribute value and set as variable


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']

Solution

  • 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}']