Hi,
I tried to convert Decimal(‘848.000000000000000000’) number to integer and getting the error message like “AttributeError: ‘int’ object has no attribute ‘lower’”
Code in Robot framework
${result}[${rowno}][7]= Decimal(‘848.000000000000000000’)
${Query_Description} = Set Variable ${result}[${rowno}][7]
${KL1}= run keyword and continue on failure convert to integer ${Query_Description}
log to console The Mesurement Value ${KL1}
Getting the error message like "
AttributeError: ‘int’ object has no attribute ‘lower’
*** Settings ***
library foo.py
*** Test Cases ***
Test Case 1
${val}= Get Dec
${KL1}= run keyword and continue on failure convert to integer ${val}
log to console The Mesurement Value ${KL1}
from decimal import Decimal
def get_dec():
return Decimal("848.000000000000000000")
This works and logs out 848 as it should … Your issue is most likely somewhere else outside of your shared code. I’d start by opening log.html and seeing what exact keyword is triggering that failure. Its way more present there than in the console.
As rasjani said, the issue might be coming from somewhere else. For example, the FOR loop that you have implemented seems bit off. Also, rasjani has provided a good example but here is one basic example using RF builtin:
Convert to integer
${number} Set Variable 848.000000000000000000
${KL1} run keyword and continue on failure convert to number ${number} 0
log to console Converted floating point value is ${KL1}
${KL2} run keyword and continue on failure convert to integer ${KL1}
log to console Converted integer value is ${KL2}
The result is:
…Converted floating point value is 848.0
…Converted integer value is 848
Convert to integer | PASS |