Hi, me again. So ive managed to work out (I think) how to save the number to a global variable but when I try to use the variable in another test im getting an error:
=============== ROOT CAUSE =====================
Caused by: groovy.lang.MissingPropertyException: No such property: myNumber for class: Script1683208133654
Reason:
com.kms.katalon.core.exception.StepErrorException: Call Test Case ‘Test Cases/BookingID for log in’ failed because of error(s)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:66)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.call(CallTestCaseKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:74)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.callTestCase(CallTestCaseKeyword.groovy:81)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.execute(CallTestCaseKeyword.groovy:44)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.keyword.BuiltinKeywords.callTestCase(BuiltinKeywords.groovy:334)
at 2 -Ocean Cruise for 2 guests a full booking for SOA products excel fiddling.run(2 -Ocean Cruise for 2 guests a full booking for SOA products excel fiddling:64)
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:448)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1683217407496.run(TempTestCase1683217407496.groovy:25)
Caused by: groovy.lang.MissingPropertyException: No such property: myNumber for class: Script1683208133654
at BookingID for log in.run(BookingID for log in:30)
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:448)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:59)
… 18 more
This is my test:
WebUI.waitForElementVisible(findTestObject(‘Search drop down/Page_Checkout/BookingID’), 15)
//Get the ID attribute value of an element and store it in a variable
String myId = WebUI.getText(findTestObject(‘Search drop down/Page_Checkout/BookingID’))
//If this comes back with alpha characters, it will fail
//Parse int will try to convert the value from a String type to a Number type
GlobalVariable.bookingId = Integer.parseInt(myId)
Then I want to use it in another test using this:
def myId = GlobalVariable.bookingId
WebUI.setText(findTestObject(‘MMB/Page_xxx/Booking number’), myNumber.toString())
to put it in this text box
this is the code:
But im struggling someone take pity on me please!