Tuesday, September 14, 2010

Using AutoIt in Selenium

First about AutoIt

AutoIt is a freeware Windows automation language. It can be used to script most simple Windows-based tasks (great for PC rollouts or home automation).

Using AutoIt, it is possible to handle the tasks that Selenium can't do. It is possible to upload/download files using AutoIt in Selenium.

Here are the ways to find a window,

Advanced Window Descriptions
A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:
  • TITLE - Window title
  • CLASS - The internal window classname
  • REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2)
  • REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2)
  • LAST - Last window used in a previous AutoIt command
  • ACTIVE - Currently active window
  • X \ Y \ W \ H - The position and size of a window
  • INSTANCE - The 1-based instance when all given properties match

Check the below docs,

Window Titles and Text (Advanced)

ControlCommand Reference

Now, How to use this Selenium?

1. Install AutoIt and write a simple script. AutoIt bundles the ScitTE editor for this. Code Editors such as Notepad++ supports AutoIt syntax.
2. Compile that script into an EXE or make a batch file to run that script.
3. Call that EXE/Batch file from your code.

I've encountered an issue when trying to run AutoIt script. It throws an DLL alert before executing the script. Installing AutoIt, solved that one. So, you may need to install the machines you want to run.

Happy Testing.


raja's shared items

There was an error in this gadget

My "Testing" Bundle