Not able to use global variable stored in test case 1 in test case 2

Scenario: Store the value of a global variable from the web end and use the same value to set text in the mobile app.
I stored a global variable value in test case1 “GlobalVariable.TextCode = WebUI.getText(findTestObject(‘Web_Application/Page_Mailinator/InvitationCode’))” and want to use the same in test case 2 but it returns nothing when I try to set the value in textbox “Mobile.setText(findTestObject(‘Mobile_Objects/Mobile_Obj_Code’), GlobalVaribale.TextCode)”.

You have this:

Mobile.setText(findTestObject('Mobile_Objects/Mobile_Obj_Code'), GlobalVaribale.TextCode)

I find a typo here.

Mobile.setText(findTestObject('Mobile_Objects/Mobile_Obj_Code'), GlobalVariable.TextCode)

kazurayam said:

You have this:

Mobile.setText(findTestObject('Mobile_Objects/Mobile_Obj_Code'), GlobalVaribale.TextCode)

I find a typo here.

Mobile.setText(findTestObject('Mobile_Objects/Mobile_Obj_Code'), GlobalVariable.TextCode)

Thanks for the reply,
But this is my mistake here but not in script.

Have you done a primitive print debuging?

testcase1:

GlobalVariable.TextCode = WebUI.getText(findTestObject('Web_Application/Page_Mailinator/InvitationCode'))WebUI.comment(">1> TextCode=${GlobalVariable.TextCode}")

and testcase2:

WebUI.comment(">2> TextCode=${GlobalVariable.TextCode}")Mobile.setText(findTestObject('Mobile_Objects/Mobile_Obj_Code'), GlobalVariable.TextCode)String txt = Mobile.getText(findTestObject('Mobile_Objects/Mobile_Obj_Code'))WebUI.comment(">3> txt=${txt}")

Lets see what happens.

I tried this but nothing happened. It throws an error " groovy.lang.MissingPropertyException: No such property: TextCode for class: internal.GlobalVariable "

I believe you have not defined the TextCode variable in the “default” Execution Property through GUI. You need to define it before your script refer to the TextCoce variable.

Please do as this:

スクリーンショット 2018-09-08 21.50.05.png

Hi all,
Can you please help me out in this?
I stored a global variable value in test case1
GlobalVariable.IMSID = findTestObject(‘Object Repository/submit booking as coordinator/Page_Interpreter Management System/bookingid’)
WebUI.comment("The answer is … " + GlobalVariable.IMSID)

I am not able to get this booking id.
it saying as object is null

You should check every single steps you make.

Try this

def testObject = findTestObject("Object Repository/submit booking as coordinator/Page_Interpreter Management System/bookingid")
WebUI.comment("The answer is … " + testObject)

and see if it is NON-null or null.