How to get text from input field ,store in a variable and use it in different test cases

Hi All,

Requirement :
1 ) Create an application with application : SampleApp + Random number Eg : SampleApp 123
2) Get Text from the input field of Application Name -
ApplicationName = WebUI.getAttribute(findTestObject(‘Object Repository/AppDef/input_Application Details_mat-input-0’), ‘value’)
ApplicationName = SampleApp 123
3) Set Text to a field to search the application by application name
Need to set text “SampleApp 123” to Search Application field

I have accomplished Step 1 and Step 2, when i tried Step 3 i get error No such property

What i have tried the below ( NONE of them worked for me)

  1. defined a global variable , assigned get attribute value , set text global variable to search application field
  2. defined a keyword , assigned value to static variable , set text to search application field
  3. defined a variable , get attribute value and then set text to search application field

Hi Srividhya1

Can you re-try with the first solutions #1: assigned global variable

1. Create the variable name at profile

2. Assuming that you can get the value ‘SampleApp 123’ at step 1 and step 2 on your test - assign the value to GlobalVariable

String ApplicationName = 'SampleApp 123'

GlobalVariable.AppName1 = ApplicationName

3. Use the global variable as below.

println(GlobalVariable.AppName1)

WebUI.setText(findTestObject('Object Repository/Page/input_username'), GlobalVariable.AppName1)

2 Likes

Thanks a lot :slight_smile: It worked!

Hi @sang ,

If the case using local variable in testcase. can I use/throw in my testcase?

Hi there, :wave:

Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.

In the meantime, you can double-check your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out this posting guide to help us help you better!

Thanks! :sunglasses:
Katalon Community team

A local variable will generally not pass its content to another Test Case except in a “called Test Case”. You can use a local variable within a single Test Case. To pass the contents of the variable to another Test Case of a Test Suite, you need a “GlobalVariable”, static variable, or as I mentioned already, a “called Test Case”.

Oh I’m understand concept local variable and global variable.

yesterday, I’m just think how I use/throw/call my local variable.
in my case, I need to verify match/ verify equal etc in my test case.
after browsing, I know to use/throw/call the variable in test case level.

its like in test case on script mode:
newVariable = ${nameVariableInTestcase}
and println newVariable
its work, what I want it. :slightly_smiling_face:

thanks @grylion54 :handshake: