Selenium Grid セットアップで AutoIT スクリプトを実行するにはどうすればよいですか?
すべてのマシンに .exe ファイルがありますが、これを呼び出してグリッドの各ノードで実行する Selenium スクリプトが必要です。これは可能ですか?
Selenium Grid セットアップで AutoIT スクリプトを実行するにはどうすればよいですか?
すべてのマシンに .exe ファイルがありますが、これを呼び出してグリッドの各ノードで実行する Selenium スクリプトが必要です。これは可能ですか?
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/
通常、autoit .exe をリソースとして .jar にパッケージ化します。次に、次のようなことができます。
// 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());