Forum Discussion
richie
5 years agoCommunity Hero
Hey sparrowenclave,
Are you saying youve already extracted the value and stored as a property already? As youve noticed poperties are stored as strings by default. Im typing this out on my phone (not sitting in front of laptop and so going on memory), but if you have the property stored at testcase level you can try the following:
// grab property from testcase level
def propStringValue = testRunner.testCase.getPropertyValue("propertyName")
//cast the string to integer type
def propStringValue = propStringValue.toInteger()
The above code will cast the string to integer type if property stored at testcase level. Youd need to edit if its stored elsewhere.
I need to highlight that HimanshuTayal gets the credit for this....i just ripped this from one of his answers!
Nice one,
Rich
Are you saying youve already extracted the value and stored as a property already? As youve noticed poperties are stored as strings by default. Im typing this out on my phone (not sitting in front of laptop and so going on memory), but if you have the property stored at testcase level you can try the following:
// grab property from testcase level
def propStringValue = testRunner.testCase.getPropertyValue("propertyName")
//cast the string to integer type
def propStringValue = propStringValue.toInteger()
The above code will cast the string to integer type if property stored at testcase level. Youd need to edit if its stored elsewhere.
I need to highlight that HimanshuTayal gets the credit for this....i just ripped this from one of his answers!
Nice one,
Rich
- HimanshuTayal5 years agoCommunity Hero
Hey!! Thanks for mentioning richie , yes you are absolutely correct.
This is happening because Properties Step stores values in (key : value) pairs which are (String : String) if you want to use it as Integer than you need to parse it into integer.
- sparrowenclave5 years agoOccasional Contributor
Agreed with your approach, but I found another way to achieve this by using DataFormatter class to get the cell content exactly present in the formatted cell and it always return a strings.
Please check the below link for more details
Related Content
Recent Discussions
- 11 days ago