Capture text and store in a variable

Good afternoon, I want to know how I can capture the value of a text on a page and store it in a variable.

Thank you very much.

1 Like

Good morning,
Thank you very much for your answer, but it is generating me error.

-Test Cases / Biohazard FAILED because (of) org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
File: / C: /Users/hvergara/Katalon%20Studio/Biohazard/Scripts/Biohazard/Script1494944557729.groovy:20: unable to resolve class internal.GlobalVariable
@ Line 20, column 1.
Import internal.GlobalVariable as GlobalVariable.

What I want to do is to capture the text that contains an element, store it in a variable, and then paste the text that is stored in the variable in a text box.

Sorry my english but I do not speak it very well and it helped me with google.

Hi there,

That error is somehow strange. Can you create another project and try again on the new test cae? What I suggest you is a correct solution and it’s not related to that error.

Thanks

Hi there,

Please use ‘Get Text’ keyword and then store it to the variable you want, e.g:

result = WebUI.``getText``(findTestObject(``'link_Register'``))

Hi

Please help me, my case is i want to copy (capture) specific word in page and then paste it in another page (text field).

Thanks

could any one tell me , i have given a command (Get Text) which will capture the text in that element, now my question is, how to store it in a variable?, how to give the path to that variable?

Thanks.

To store the value in a variable and then use it again would be:
h3HeaderText = WebUI.getText(findTestObject(‘H3 Header Text’))

To use the variable would be:
WebUI.setText(findTestObject(‘Input Field’), h3HeaderText)

If you want to use Global Variables, you can use:
GlobalVariable.h3HeaderText = WebUI.getText(findTestObject(‘H3 Header Text’))

And then define the Global Variable as part of your Execution Profile

1 Like

This type of request is going trendy, and the following feature may suits your needs. If you think it does, you may upvote it for Katalon guys to add it in a further release :