Tuesday, August 21, 2012

Handling alert box using AutoIT

AutoIT is a scripting language designed for automating the Windows GUI. It uses simulated keystrokes, mouse movements and window manipulations.

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



Step 1: 

Download the latest version of AutoIT.

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");



5 comments:

  1. Hi,

    Can we use this AutoIT for hover over main menu A, hover over sub menu b and finally click on sub menu c

    Website is www.hdfcbank.com

    Main menu A is " Find your nearest" ( i am able to do this using actions driver concept)

    Submenu B is "ATM" ( i am able to do this using actions driver concept)

    Submenu C is "All ATMs" ( I am not able to click this Submenu C)

    Kindly give your inputs.

    Thanks,

    EJ

    ReplyDelete
  2. Hi,

    I could finally make my code work using this code

    fc.findElement(By.linkText("All ATMs")).sendKeys("\n");

    Thanks,

    EJ

    ReplyDelete
  3. Hi, the below is not working in selenium web driver.. It it giving the error..Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

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

    Here is my full java code; please help me with this

    import java.io.IOException;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import java.lang.Runtime;

    public class Login_AutoIT {
    public static void main(String[] args) throws IOException{
    Runtime.getRuntime().exec("C:\\AutoIT-Selenium\\AutoITpopuphandler.exe");


    {
    Runtime.getRuntime().exec("C:\\AutoIT-Selenium\\AutoITpopuphandler.exe");
    }*/

    WebDriver wd = new FirefoxDriver();
    wd.get ("complete url");
    }

    ReplyDelete