Prompt for user input then add value to a variable

Hoping you can help - I am new to Katalon and still learning the ropes.

I need to be able to add a prompt, for user input, into a Web UI script.
The value entered into the prompt by the user running the script at runtime, then needs to be stored into a variable, that I can use within the script at a later point (SetText in a field).
The variable is called “MFACode”

Please can you help? Is this possible and if so, what is the code to achieve this?

Thanks in advance!

That’s a bit counter intuitive to automated testing.
My only ideahere would be to have a batch file asking for user input and starting the test with a specific global variable.

I appreciate your quick response. Here is my scenario to give some context,which is to test a login process with multi-factor authentication

1). Login to web site using Username and password chars x, y and z as requested
2). A randomly generated code is sent to a registered mobile phone as SMS (“MFACode”)
3). User needs to enter code to complete login process

Open to suggestions as to how Katalon studio could support this!

  1. Should be easy enough to do. Register username and password object and use setText().
  2. Many possibilities for this. I think it should be done server side to bypass the generated code during automated testing. It’s similar to the captcha plugin.
    However, if there’s a way to access your MFACode from another website (so you could navigate there and get it) or someway to write your MFACode in a texte file or a database, you can then read the file and write the code.

Basically Katalon Studio is limited to what you can develop. In my applications, things like 2FA, passwords, captcha are removed in testing environment.

I have the same issue as discussed here. I am very new to Katalon and would appreciate an example of how to accomplish this. Has anyone ever come up with an actual coded solution?

My suggestion would be to put in a 15 second delay, WebUI.delay(15), (you may have to play with the timing) in which you have your time to enter your “code”. I’m assuming the text you’re trying to enter cannot be done by a WebUI.setText().

Another idea would be to do your testing in parts and prepare a spreadsheet or text file with your code. Then you can read in the spreadsheet or text data. Information on how to do that is in this forum.

Thanks for the quick reply. But here is my issue. When I log into my URL, I get the Global Logon.

I save the process in the following script:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys


WebUI.navigateToUrl(‘https://My.URL.PAGE’)‘Object Repository/Page_ATT Security Server Login/body_div idnoscript_error div idnosc_863b27’))‘Object Repository/Page_ATT Security Server Login/body_div idnoscript_error div idnosc_863b27’))

WebUI.setText(findTestObject(‘Object Repository/Page_ATT Security Server Login/input_ATTUID_userid’), ‘MyUID’)

WebUI.setEncryptedText(findTestObject(‘Object Repository/Page_ATT Security Server Login/input_Enter 8-digit passcode here_tokenpin’), **
** 'MyPWD)‘Object Repository/Page_Security Server Successful Login/input_ITSERVICES Password_successButtonId’))

I am ~really~ new to Katalon and need to know what to update in the script and where in order to have the user run the script and add their UID & PWD when called for.

Any help will be appreciated.


If you are starting at the very beginning, I would suggest viewing some of the multitude of videos on KS. They can provide more information than I via chat sessions. As for your UID and PWD, you have them identified in your code–MyUID and MyPWD–so I’m not sure about your question? (For testing, maybe you can hard-code something that has “Testing” access.)

If you need a break in your code, then I have used just a “delay” to give me the moment to enter in my code, such as your RSA SecurID. However, you may not need that if you go with providing a correct username and password since it seems you have options.

Note: if you are using the Web Spy, you need to ensure you have the correct element in contact with the Spy and not just “close enough”.

Also note: don’t put anything in this forum that is confidential or proprietary. You can always fudge and edit the script to simplify, like “myPage/idnosc_863b27”. Takes a bit more time, but keeps the confidentiality.