I want the Script to Openfile.exe
only if the previous one i.e CreateNew.exe
has finished executing.
Right Now whats happening is, when I run TestNG.xml
file it runs all the @Test
priority wise and within 5 sec TestNg
output console shows all the @Test
are passed.
While my AutoIT scripts are still running in parallel in background.
The code is as follows:
@Test (priority=1)
public void CreateNew() throws Exception
{
Runtime.getRuntime().exec("exeFiles\\CreateNew.exe");
}
@Test (priority=2)
public void OpenaFile() throws Exception
{
Runtime.getRuntime().exec("exeFiles\\OpenaFile.exe");
}
And the code of AutoIt file is as Follows:
createnew()
Func createnew()
Sleep(2000)
Run("Mspaint.exe")
WinWaitActive("Untitled - Paint")
Send("!f")
Sleep(1000)
Send("n")
Sleep(2000)
WinClose("Untitled - Paint")
EndFunc ;==>createnew
A possible solution for this can be:-
- In your Java/Selenium code create a temparory lockfile
- Start Autoit.exe
- In your Java/Selenium code write a loop to check if lockfile still exists
- Last step in the AutoIt code removes the lockfile
- If the lockfile doesn't exist break out of loop and continue with the next code
Now does anyone know how to create and use this lockfile in code?