Note that there are some explanatory texts on larger screens.

plurals
  1. PORun bat file from java code and wait for it to execute TestComplete script - no can do :(
    primarykey
    data
    text
    <p>I am writing this question which is related to my previous topic:</p> <p><a href="https://stackoverflow.com/questions/6856813/run-bat-file-from-java-code-to-get-desired-result-in-txt-file-no-can-do">Run bat file from java code to get desired result in txt file - no can do :(</a> In a shortcut: i wrote a program in java that runs a bat file. This bat file runs TestComplete8 script that performs desktop application test. After test is finished, bat file generates file called result.txt and prints information about test to it. I'm stuck with another issue right now: Now from my java code i would like to wait until the bat run is finished. I do that by looping until the file called result.txt exists. Not the nicesest solution i guess but I thought it could work, also tried different solutions. What happens is that it will loop fine and wait until file exists, but testcomplete doesn't perform the test. It is very strange, because testcomplete runs, i can see that test starts, my AUT starts as well, but than nothing happens. Testcomplete is waiting for any object and doesn't click anywhere just waits until predefined time for action runs out. When i run the test without any waiting done in code, everything is fine. I just don't understand why nothing happens during the test when waiting is enabled and why it works fine when i just remove any do - while or waitFor(), or even i tried running it in seperate threads. :(</p> <p>I have a feeling that it may be somehow related to the OS and have something to do with processes as it runs something like a bat as process and than bat runs it's child process as testcomplete or sth like that. Thanks for any answers</p> <p>Source code as asked: Right now i was trying a solution with modified bat file:</p> <pre><code>@ECHO OFF "C:\Program Files (x86)\Automated QA\TestComplete 8\Bin\TestComplete.exe" "C:..." /r /p:projname PathToApp="C:\...p" Login=... Password=B1 /t:"KeywordTests|..." /exit </code></pre> <p>and the code to run and wait in latest version is:</p> <pre><code> new Thread(new Runnable() { public void run() { File file = new File("D:\\"); int exitValue = -1; try { Process process = Runtime.getRuntime().exec(batch, null, file); while (true) { try { exitValue = process.exitValue(); System.out.println(exitValue); break; } catch (IllegalThreadStateException e) { // e.printStackTrace(); try { Thread.sleep(1000); } catch (InterruptedException e1) { e1.printStackTrace(); } System.out.println("Waiting for process..."); } } } catch (IOException e) { e.printStackTrace(); } } }).start(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload