Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find lowest value in the list using Robot Framework?

I'm trying to find the lowest value in the list using Robot Framework. I have written custom keyword in python as below:

 def Minimum_Value_from_list(self, list_):

    return min(list_)

I have executed the below RF script

Find lowest value
    @{list}=    Create List     3    5    9   16    31    42    66     75
    Log List    ${list}
    ${LowValue}=    Minimum_Value_from_list    ${list}

It shows the output(minimum value) as 16 which is not correct.

Any inputs/suggestion would be helpful to get the correct output

like image 576
Manish Kumar Avatar asked Jan 26 '23 18:01

Manish Kumar


1 Answers

By default, robot will pass the values as strings. You'll need to convert them to integers before getting the minimum value.

If you can safely assume all of the values are indeed integers, one way to do it would be with a list comprehension:

return min([int(x) for x in list_])
like image 155
Bryan Oakley Avatar answered Feb 14 '23 02:02

Bryan Oakley