Can anyone guide me that what I am doing wrong for calculation
net_total = WebUI.getText(findTestObject(‘V3-VAT/Page_Lead/Page_New Lead - new-lead-1/Net_Amount_V3’))
‘Calculation cash and chq’
Example net_total = 945 , so 945 - 200 will be 745 will store in cash_amount , but below calculation is ot working
cash_amount = (((net_total) - 200))
chq_amount = ((net_total) - cash_amount)
is there any simple way to do it ?
This should give you a starting point.
//Converting strings to numbers
def net_total = '945' as int
def cash_amt = '200' as int
def chq_amount = net_total - cash_amt
println('chq_amount: ' + chq_amount)
//Result: chq_amount: 745
//Converting strings with decimals
def netTotal = '100,000.50'
netTotal = netTotal.replace(',', '')
BigDecimal netTotalDec = new BigDecimal(netTotal)
def cashAmt = '100,000.50'
cashAmt = cashAmt.replace(',', '')
BigDecimal cashAmtDec = new BigDecimal(cashAmt)
println('netTotalDec: ' + netTotalDec + ' cashAmtDec: ' + cashAmtDec)
def chqAmount = netTotalDec - cashAmtDec
println('chqAmount: ' + chqAmount)
//Result:
//netTotalDec: 100000.50 cashAmtDec: 100000.50
//chqAmount: 0.00
Hi @noor.ahmed,
Just checking in to see if Dave’s comment has been able to help you or not. Do remember to follow up with him until you reach a solution.
Thanks! 