Hello Team,
I need help with a BigDecimal Value.
The issue is I have a scenario where I am grabbing a price from website in BigDecimal datatype and then verifying if it is equal to my expected value, both the price and expected value are in BigDecimal. The expected value I am calculating is within the script
total_item_wise_after_increment_1 = WebUI.getText(findTestObject('4_Shopping_Cart_Page/Total_Item_Wise')).replace('$', '')
BigDecimal total_item_wise_after_increment = new BigDecimal(total_item_wise_after_increment_1)
WebUI.println('Total for the Item on Shopping Cart Page after increment is : ' + total_item_wise_after_increment)
/* Calculating Expected Total */
expected_total_item_wise_after_increment_1 = total_item_wise.multiply(expected_quantity_shopping_cart_after_increment)
BigDecimal expected_total_item_wise_after_increment = new BigDecimal(expected_total_item_wise_after_increment_1)
WebUI.println('The expected total item wise after increment should be : ' + expected_total_item_wise_after_increment)
/* The Script will now verify if expected total item wise is equal to what shows up on the Shopping Cart page */
assert expected_total_item_wise_after_increment.equals(total_item_wise_after_increment)
Upon executing the Script I am getting this error :
Assertion failed:
assert expected_total_item_wise_after_increment.equals(total_item_wise_after_increment)
| | |
| false 242.45
242.44999999999998863131622783839702606201171875
I tried to Use Rounding method but that doesnât work all the time, The price will change every time I run the test case.