scenario is including following steps:
- Take the cost value in one variable and do same for all cost present on the page
- Add all the variables.
- Compare with total cost displayed on page.
I am not able to add the variables.
Please help me.
You probably use WebUI.getText() to get numbers, so you must convert String variable to float/double.
String var1 = "17.5"
String var2 = "5.555"
Double number1 = Double.parseDouble(var1)
Double number2 = Double.parseDouble(var2)
println number1 + number2
Can I store the result of number1 + number2 in one variable?
Thank u for your quick reply.
Of course, but the variable must be Double type (and it could be casted afterwards if you want)
Double result = number1 + number2
// if you want to have String result
String resultAsString = result.toString()
I have tried it and it works,