Ask a Question

I want to enter value in a popup text box using groovyscript can some one suggest me how to do that?

Occasional Visitor

I want to enter value in a popup text box using groovyscript can some one suggest me how to do that?



While running groovy script I am getting one pop up text box to enter some values and below that text box i am getting "okay" and "Cancel" button can someone suggest me how to enter value in that pop up text box and click on Okay button using groovy script.



Note: On Right click there is not get data option present

Champion Level 2

Hi @Sandeep96 ,


I don't quite follow.  You run a Groovy script that presents a modal window and you want to populate that via Groovy script?  Have to admit, I have never seen Groovy display a modal window.  Can you clarify further and possibly add the script and some screenshots?



Occasional Contributor


with this Groovy script:


import javax.swing.*

def popup = {
JFrame jframe = new JFrame()
String answer = JOptionPane.showInputDialog(jframe, it)

def mytext = popup("Enter a text") "text inserted: " + mytext


I'm able to enter a value in a popup:



Hello @Ilario72 

Here is a sample that captures the content entered into a prompt from a groovy script.  I am not aware of external tools that run against groovy to press buttons for you however.  Like ChrisAdams indicated that is a very odd use case and I am just hoping i am misinterpreting the question. 'Test Step "' + + '" start...'; "";

def testcaseNameFilePath = 'C:\\Temp\\FHIR MolecularSequence Testcase Files\\';
def titleStr = 'Prompt';
def questionStr = 'Path of input testcase name files?                                         ';
def valueStr = testcaseNameFilePath;
def fileInput =, titleStr, valueStr).toString();
assert (fileInput), "Path can not be empty"; "fileInput response=$fileInput";
//testRunner.testCase.testSteps["Properties"].setPropertyValue( "testcaseNameFilePath", fileInput); ""; 'Test Step "' + + '" finish...';
Community Hero

Hey @Sandeep96 


sorry Im a little late in responding as I've been on holiday.


I'm intrigued by this - can I ask:


- what's the purpose of the groovy script?  why would a script that halts the execution of the testcase be added?

-after inputting a value into the editable field and selecting 'OK' to submit the value, how is this value being used later in the script?

- the groovy script test step in the image you provide - is there further groovy in the step or is what is displayed in the image the entirety?

-if the value is used by other steps in your testcase, would it not increase efficiency/automation by finding another means of providing this value - i..e then allowing you to remove the groovy step completely?





if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

I think @Sandeep96 answered his own question.


I think the requirement was... "Using Groovy script, how do I display a pop-up/modal window; let the user input text; capture the answer in a variable?".

Showing results for 
Search instead for 
Did you mean: