Forum Discussion

Sandeep96's avatar
Occasional Visitor
3 years ago

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

5 Replies

  • ChrisAdams's avatar
    Champion Level 3

    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?



  • Ilario72's avatar
    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:


    • TNeuschwanger's avatar
      Champion Level 2

      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...';
  • richie's avatar
    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?





    • ChrisAdams's avatar
      Champion Level 3

      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?".