Need help with an Issue

Hello Team,

I am facing a programming problem and not able to figure out what I am doing wrong. I have below piece of code with which I am doing some validations on a Shopping Cart page

========================================================

window_title = WebUI.getWindowTitle()

WebUI.verifyMatch(window_title, 'Your Shopping Cart.*', true)

shopping_cart_product_quantity_initial = WebUI.getAttribute(findTestObject('4_Shopping_Cart_Page/Shopping_Cart_Product_Quantity'), 
    'value')

assert shopping_cart_product_quantity_initial.equals('1')

WebUI.println('The current shopping cart quantity is : ' + shopping_cart_product_quantity_initial)

int randomnumber = new Random().nextInt((50 - 1) + 1) + 1

WebUI.println('The random number generated is  : ' + randomnumber)

for (int i = 0; i < randomnumber; i++) {
	
    WebUI.click(findTestObject('4_Shopping_Cart_Page/Button_Increase_Quantity'))
}

WebUI.println('The value after running for loop is  : ' + randomnumber)

expected_shopping_cart_product_quantity = (shopping_cart_product_quantity_initial + randomnumber)

shopping_cart_product_quantity_2 = WebUI.getAttribute(findTestObject('4_Shopping_Cart_Page/Shopping_Cart_Product_Quantity'), 
    'value')

WebUI.println('The expected shopping cart quantity should be  : ' + expected_shopping_cart_product_quantity)

assert shopping_cart_product_quantity_2.equals(expected_shopping_cart_product_quantity)

========================================================================

When I execute this I am getting below error, It seems to be calculating expected_shopping_cart_product_quantity wrong.

2019-04-30 11:35:57.716 DEBUG Test Functionality of Update Cart Button - 22: window_title = getWindowTitle()
2019-04-30 11:35:57.731 DEBUG Test Functionality of Update Cart Button - 23: verifyMatch(window_title, "Your Shopping Cart.*", true)
2019-04-30 11:35:57.737 DEBUG Test Functionality of Update Cart Button - 24: shopping_cart_product_quantity_initial = getAttribute(findTestObject("4_Shopping_Cart_Page/Shopping_Cart_Product_Quantity"), "value")
2019-04-30 11:35:57.766 DEBUG Test Functionality of Update Cart Button - 25: assert shopping_cart_product_quantity_initial.equals("1")
2019-04-30 11:35:57.768 DEBUG Test Functionality of Update Cart Button - 26: println("The current shopping cart quantity is : " + shopping_cart_product_quantity_initial)
The current shopping cart quantity is : 1
2019-04-30 11:35:57.771 DEBUG Test Functionality of Update Cart Button - 27: randomnumber = Random().nextInt(50 - 1 + 1) + 1
2019-04-30 11:35:57.775 DEBUG Test Functionality of Update Cart Button - 28: println("The random number generated is  : " + randomnumber)
The random number generated is  : 4
2019-04-30 11:35:57.776 DEBUG Test Functionality of Update Cart Button - 29: for ([i = 0, i < randomnumber, (i++)])
2019-04-30 11:35:57.777 DEBUG Test Functionality of Update Cart Button - 1: click(findTestObject("4_Shopping_Cart_Page/Button_Increase_Quantity"))
2019-04-30 11:35:57.844 DEBUG Test Functionality of Update Cart Button - 1: click(findTestObject("4_Shopping_Cart_Page/Button_Increase_Quantity"))
2019-04-30 11:35:57.915 DEBUG Test Functionality of Update Cart Button - 1: click(findTestObject("4_Shopping_Cart_Page/Button_Increase_Quantity"))
2019-04-30 11:35:57.965 DEBUG Test Functionality of Update Cart Button - 1: click(findTestObject("4_Shopping_Cart_Page/Button_Increase_Quantity"))
2019-04-30 11:35:58.010 DEBUG Test Functionality of Update Cart Button - 30: println("The value after running for loop is  : " + randomnumber)
The value after running for loop is  : 4
2019-04-30 11:35:58.011 DEBUG Test Functionality of Update Cart Button - 31: expected_shopping_cart_product_quantity = shopping_cart_product_quantity_initial + randomnumber
2019-04-30 11:35:58.012 DEBUG Test Functionality of Update Cart Button - 32: shopping_cart_product_quantity_2 = getAttribute(findTestObject("4_Shopping_Cart_Page/Shopping_Cart_Product_Quantity"), "value")
2019-04-30 11:35:58.038 DEBUG Test Functionality of Update Cart Button - 33: println("The expected shopping cart quantity should be  : " + expected_shopping_cart_product_quantity)
The expected shopping cart quantity should be  : 14
2019-04-30 11:35:58.039 DEBUG Test Functionality of Update Cart Button - 34: assert shopping_cart_product_quantity_2.equals(expected_shopping_cart_product_quantity)
2019-04-30 11:35:58.046 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/QATB-47 - Shopping Cart Validations/QATB-48 - Test Functionality of Update Cart Button FAILED.
Reason:
Assertion failed: 

assert shopping_cart_product_quantity_2.equals(expected_shopping_cart_product_quantity)
       |                                |      |
       5                                false  14

	at QATB-48 - Test Functionality of Update Cart Button.run(QATB-48 - Test Functionality of Update Cart Button:101)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:336)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:327)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:306)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:298)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:232)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1556649318071.run(TempTestCase1556649318071.groovy:21)

2019-04-30 11:35:58.047 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/QATB-47 - Shopping Cart Validations/QATB-48 - Test Functionality of Update Cart Button

@Russ_Thomas I updated the post with formatting. Will keep this in mind in future

1 Like

Update : This statement takes value from “value” attribute and that attribute is showing correct value

I am still facing the same issue

I am using Katalon studio from last month.
Functionally it does great job but when it comes to parallel execution then I am stuck at one point.
When I run 3 suites (with same set of test cases) having small test cases then it runs in parallel with out any issue but as soon as the parallel suite thread count increases to 10 or even 5 in this case katalon start behaving strange.
some parellel suites gets completed as expected and some gets failed and katalon hangs for some time.

Can any one tell me the solution as katalon is providing clear option to run huge number of parallel suites (around 1000) then why it is not executing at 10 or 5 ?

My machine config are good 3 ghz CPU, 4GB RAM.
Please help me