The absolute value of the robot (number)

Looking for a way to represent module / absolute value in Robot Framework. Is it abs ()? or $ {variable} .abs ()? How can I make my $ {variable} with a negative value of -15 equal to +15

Like this: | -15 | = 15

+4
source share
2 answers

You need to use the Evaluate keyword to run the abs function on your number:

*** Variables ***
${neg num}     -15

*** Test Cases ***
Absolute
    Log    ${neg num}
    ${num}=    Evaluate    abs(${neg num})
+8
source

If you need an alternative to Pekka, the best answer is here:

*** Variables ***
${var}     -15

*** Test Cases ***
Absolute
  Log    ${var}
  ${abs var}=    Set Variable    ${var.__abs__()}
+3
source

Source: https://habr.com/ru/post/1606557/


All Articles