Forum Discussion
5 Replies
- ChrisAdamsChampion 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?
Chris
- Ilario72Occasional Contributor
Hi,
with this Groovy script:
import javax.swing.*
def popup = {
JFrame jframe = new JFrame()
String answer = JOptionPane.showInputDialog(jframe, it)
jframe.dispose()
answer
}def mytext = popup("Enter a text")
log.info "text inserted: " + mytextI'm able to enter a value in a popup:
- TNeuschwangerChampion Level 1
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.
log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" start...'; log.info ""; def testcaseNameFilePath = 'C:\\Temp\\FHIR MolecularSequence Testcase Files\\'; def titleStr = 'Prompt'; def questionStr = 'Path of input testcase name files? '; def valueStr = testcaseNameFilePath; def fileInput = com.eviware.soapui.support.UISupport.prompt(questionStr, titleStr, valueStr).toString(); assert (fileInput), "Path can not be empty"; log.info "fileInput response=$fileInput"; //testRunner.testCase.testSteps["Properties"].setPropertyValue( "testcaseNameFilePath", fileInput); log.info ""; log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" finish...';
- richieCommunity 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?
Cheers,
Rich
- ChrisAdamsChampion 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?".
Related Content
- 2 years ago