How can I run an AutoIT script over a Selenium Grid set up?
I have the .exe file on all machines but need to have the Selenium Script to call this to run on each node of the grid, is this possible?
How can I run an AutoIT script over a Selenium Grid set up?
I have the .exe file on all machines but need to have the Selenium Script to call this to run on each node of the grid, is this possible?
Your question (at time of this writing) isn't very detailed about your specific test setup for grid deployment. So an exact answer can't be proposed as it depends on how your environment is set up.
The simplest approach is to use PSExec.exe, telnet, or SSH to remotely call AutoIt on the node machine from your test execution machine. A simple example is given below, note that I have not tested the code, but should work with minor tweaks if needed.
String cmd = "C:\\LocalMachinePathTo\\psexec.exe \\\\%s -u %s -p %s -i C:\\GridNodeMachinePathTo\\autoit.exe";
Process p = Runtime.getRuntime().exec(String.format(cmd,gridNodeHostName,gridNodeWindowsLoginUserName,gridNodeWindowsLoginPassword);
p.waitFor();
The simple example assumes you use the native local desktop (or console/head) session of the grid node machine for running automated tests, and not using a remote desktop session to the grid node. If the latter, you would then need to supply a session ID after the -i parameter to psexec.exe. You can find more info on PSExec.exe here:
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
The code presented is simple example, you may prefer to add additional logic to check if test is executing locally or over grid, where if executing locally, your command can omit use of psexec and just call autoit.exe directly.
Read these blog posts for more details/insight into making AutoIt run with tests on Selenium grid:
https://autumnator.wordpress.com/2011/12/22/autoit-sikuli-and-other-tools-with-selenium-grid/
This should work for you:
String cmd = "C:\\PathToExe\\autoit.exe";
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
I usually package the autoit .exe as a resource into the .jar. Then you can do something like this:
// locate an executable script in the resources
URL res = getClass().getResource("/autoit/autoit_helloworld.exe");
// locate the script in the filesystem
File f = new File(res.file);
assertTrue(f.canExecute());
Process prog = Runtime.runtime.exec(f.canonicalPath);
assertEquals(0, prog.waitFor());