Friday 22 November 2013

Handling Alert Boxes Using AutoIT in Selenium

Handling alert box using 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!.

Here we are going to use AutoIT for handling authentication boxes like below,



Step 1: 

Download the latest version of AutoIT from http://www.autoitscript.com/site/autoit/downloads/
 

Step 2: 

Write the code and Save it as 'Authentication.au3' 
(au3 is the AutoIT format)



Use the below code
WinWaitActive("Authentication Required")
Send("Username")
Send("{TAB}")
Send("Password")
Send("{ENTER}")

Step 3:

After that, right click on your Authentication.au3 file and click 'Compile Script'
This will covert your AutoIT script into an executable file

Step 4:

Now go to your Selenium code, and add the below line.

Runtime.getRuntime().exec("C://Path//Authentication.exe");

6 comments:

  1. Hi Ruchi Goyal Ji,
    Thanks for the post.Please keep sharing your knowledge and experience of selenium webdriver(automation) programs with us.

    ~Thank You.

    ReplyDelete
    Replies
    1. Hi Ramesh,

      I'm palani from bangalore. I'm trying to contact you by mail. Can you please reply to my email:palanivelgen@gmail.com regarding ramesh sir selenium training.

      Delete
  2. We Can Use Java Robot Classes instead of using 3rd party Tool too..

    ReplyDelete
  3. Thanks a tonne Ruchi....problem solved :)

    ReplyDelete
  4. Thanks a lot Ruchi.. solved my problem

    ReplyDelete