Skip to content

Debugging tests and issues regarding AutoIt and AutoItDriverServer

David Luu edited this page Feb 1, 2015 · 6 revisions

Issues or exceptions you encounter may be specific to AutoItDriverServer or equally likely AutoIt/AutoItX itself.

Because the problem may not be with the AutoItDriverServer but rather AutoIt. Just like when you have Selenium WebDriver test that fails to find locator, you would likely debug by trying to see if the browser can find/detect the locator using Firebug/FirePath/Firefinder, browser developer tools, and like tools to find the element or test the locator value (CSS/XPath).

And then from there, a next step for some of you may be to try to interact with the element from within browser via javascript code execution via browser developer/javascript console, e.g. something like document.getElementById('someId').click(); or var imgUrl = document.querySelector('CSS selector value for image element').src; and see if the interaction or data extraction succeeds.

If it works in browser, it should ideally work in Selenium, except where there are Selenium bugs.

Similarly, you need to do the same with AutoIt vs AutoItDriverServer. When it fails with the server, and the error/failure doesn't appear straightforward as server specific, test/debug natively in AutoIt script or AutoItX COM API calls to narrow down and/or confirm the problem. If it doesn't work via AutoIt/AutoItX, then the problem is not with the server.

As there are multiple ways to use and debug with AutoIt/AutoItX, I won't list examples and info here. You can do your research online for example code, etc. or try the AutoIt support forum, particularly the AutoIt ActiveX/COM help forum if you are using AutoItX/COM and also because the AutoItDriverServer uses the AutoItX COM API internally.

This AutoIt function reference is also useful when debugging AutoIt: https://www.autoitscript.com/autoit3/docs/functions.htm

There are 2+ options in general for debugging AutoIt, depending on your preference:

  • write the AutoIt code in native AutoIt script language then run it via AutoIt or compile to executable to run/deploy anywhere

  • write as AutoItX COM (or less likely C/C++ DLL) API calls using your preferred programming language (Java, .NET, Python, Ruby, node.js, Perl, PHP, VBScript, etc.). If you ask me personally, when debugging or testing this route, I prefer VBScript since it's available on all Windows computers without any extra installation or setup (.NET COM interop, .NET reg free COM, Java COM bindings, installing Java/.NET/Python/Ruby/etc.)

  • use the au3int tool to test AutoIt script code in an interactive interpreter shell instead of write/edit/run an AutoIt au3 script to test/debug.

  • use the "run a single line of code" feature of AutoIt as described in here to execute AutoIt script code w/o having to write/edit/run an AutoIt au3 script to test/debug.

Tips on AutoIt failures/problems and possible workarounds:

AutoIt isn't the best or a perfect Windows desktop GUI automation tool. But it is a good/useful one. So as such, there are times you may find it hard to find a "correct" or "proper" locator value that defines a element/object or "control" as AutoIt calls that. If you can't find any working locator value, you have to resort to other workaround techniques. Sometimes there are workarounds, sometimes not. Here are some tips on that below.

  • if what you need to do is click element, etc. you can workaround using mouse x,y coordinates to click against, drag and drop against, etc. instead of clicking based on element locator. And for this technique sometimes better to use relative coordinates (relative to the active window) or absolute coordinates. The coordinate option is configurable at server startup or via desired capabilities when connecting to AutoItDriverServer with WebDriver client. See WebDriver API command support and mapping to AutoItX API for details.

  • if what you need to do is get element text, coordinate location, size, etc. you might be out of luck. No workarounds. Or sometimes, workaround by using image recognition tools, such as Sikuli, AutoPy, etc. to find element where AutoIt fails. For these other tools, you can either use them natively or try the WebDriver wrappers for them: AutoPyDriverServer, SikuliDriverServer