How can i save value i get to globalVariable?


i would like to store some values direct into existing GlobalVariable.‘variable’. Problem is that this doesn’t work, have you any solution please?
Value i get :
Text of object ‘Object Repository/_RepositoryBE/Page_Search_Ad/NewAdCreatedID’ is: ‘346318847’
And i tried to save it into GlobalVariable.‘variable’ itself, GlobalVariable.‘variable’.Value (didn’t work) and a few more options.
Important to say, that value IS stored in global variable, but in case of current test run. After test case is done - value disappeared.


Hey Fcrtechtesting!

For this case you should use Keywords and create a class with your own global variables.

I for example have a custom keyword called MyVariables.groovy:

package customKeywords

public class MyVariables {

	public static String testSubstance = SmallFormMethods.substanceGenerator()
        publicstatic String testText

In this case the saved attribute will be given to another keyword which is a function.

In the test case you simply add your keyword like this:

WebUI.setText(findTestObject('ALLG-TF-Focused-Input'), MyVariables.testSubstance)
WebUI.getText(findTestObject('ALLG-TF-Focused-Input'), MyVariables.testText)

I hope that works fine for you! The value is definitely saved after the test run, it definitely works for me for a while now :).

what mean this worked for u ? how come