Using selenium we can upload a file. So then what is the purpose of the autoit tool in selenium?

driver.findElement(By.id("image")).click();

username.sendKeys("D:\Images\img.jpg");

The above code is enough to upload an image to our web application. Then what is the need for autoit in selenium? Is there any other specific feature in autoit?

It is used to help automate dialog boxes, window alerts, Authentication pop-ups, etc. Downloads is one of these.

From: http://toolsqa.com/selenium-webdriver/autoit-selenium-webdriver/

Web applications do not always confine themselves to working entirely on the web. Sometimes they need to interact with the desktop to do things like downloads & uploads. Automating these sorts of workflow is tricky in Selenium. Selenium is confined to automating browsers, so desktop windows are out of scope. If you are looking to automate workflows that go from browser to desktop and back in Selenium, then a little AutoIt is in order.

What is AutoIt

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required! In layman’s term AutoIt is just another automation tool like Selenium but unlike Selenium it is used for Desktop Automation rather Web Automation. It is a powerful tool and it just not automate desktop windows, button & form, it automates mouse movements & keystrokes too. Just like Selenium IDE, it also gives you the recording capability which generates the scripts for you to use the same script in you test.

Autoit tool is not only used for uploading files, autoit also deals with downloads, handling user authentications, managing keystrokes, mouse movements and handling user controls. Moreover, "sendkeys" doesn't works every time to upload files. Basically Autoit is scripting language designed for automating Windows GUI. Some of the features of autoit are as under:

  1. While automating you will come across many scenarios where you need to type text or press any key from keyboard in a windows dialogue box where selenium can't help. In these situations Autoit comes into rescue. Thus autoit can be considered as Keystrokes Simulator.
  2. There can be situations where you will require movement of mouse, again autoit can do easily solve your problem. In other words, mouse movements can also be handled by autoit.
  3. Apart from these simulating keystrokes and mouse movements, with the help of autoit, you can perform any activity which you do manually with window. Like move, hide, show, resize, activate, close etc. You can directly get information on and interact with edit boxes, check boxes, list boxes, combos, buttons, status bars without the risk of keystrokes getting lost. Even work with controls in windows that aren’t active!
  4. You can find all the functions and methods with detailed explanation and examples under help menu of AutoIt. Thus making the tool easier to learn.

https://en.wikipedia.org/wiki/AutoIt - is Windows scripting freeware.

So if you use it, you locked yourself to MS Win platform. Why would anyone want to do that? Especially if Selenium is multiplatform? And Linux has much better universal scripting languages, like Python? Which also works on Windows?

Or in worst case, use IronPython for windows to integrate with window's object model. Works nicely, from personal experience.

So I do not see the reason to use AutoIt. It's purpose is to chain you to Windows platform. First released 1997, ecosystem changed significantly since then and I do not see why anyone would prefer it over Python/IronPython. I will see in comments what AutoIt has what IronPython is missing, if any.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.