Sanna R
Sanna R

Reputation: 13

How to return values from autoit script to selenium

How to return values from autoit script to selenium?

I want to return string value from autoit to selenium

String t = Runtime.getRuntime().exec("D:\\AutoItScipts\\downloadWindow.exe");
System.out.println(t);

Thanks,

Upvotes: 0

Views: 1828

Answers (1)

LittlePanda
LittlePanda

Reputation: 2507

Read the InputStream of the process:

Process p = Runtime.getRuntime().exec("your autoIT exe file path");

BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line;
while ((line = input.readLine()) != null) {
  System.out.println(line);
}

And then, method waitFor() will make the current thread to wait until the external program finishes and returns the exit value.

int exitVal = p.waitFor();
System.out.println("Exited with error code "+exitVal);

And in your AutoIT script, you have to probably write output to the console (please try):

ConsoleWrite("data")

Upvotes: 2

Related Questions