AutoIT V3 Tutorial | Download and installation steps | Practical Demo with Selenium And TestNG



Hello Friends,

In this article we are going to learn about AutoIT.

Have you ever faced a problem while downloading files from web Application or uploading files in web Application and handling windows based alert or pop ups.

Yes, if you are using Selenium WebDriver then you definitely went through this situation.

So for that purpose only I have decided to write a simple article on AutoIT so it is useful for the beginner as well as experienced people.

To watch practical demo click on URL : Practical demo of AutoIT

Below are the questions which we are going to discuss in this article:

1. What is AutoIT ?
2. Why to use AutoIT ?
3. How to download and setup AutoIT on windows system
4. How to write AutoIT script
5. How to automate application using AutoIT, Selenium And TestNG

So let’s get started and learn step by step

1. What is AutoIT ? 

  • AutoIT or AutoIT V3 is a freeware   scripting language tool and it is used for automating windows based GUI.
  • AutoIT scripting language is written in a BASIC language and it uses group of mouse movement, window/control and keystrokes manipulation to execute/automate the task which is not feasible by selenium WebDriver class.

2.  Why to use AutoIT ?

  • To handle windows based alert box or pop-ups
  • To Upload the files in web application
  • To download the files from web application

3. How to download and setup AutoIT

  • To download AutoIT setup use the below steps  and it contains the below tools  or editors available.
    • SciTE Script Editor  //Where we can write the AutoIT Script
    • AutoIT Window Info  // Using this tool we can find out or locate the window elements
    • AutoIt Script to Exe converter  //This is optional tool to compile and to convert script into exe.
  • Steps to download the setup :
    • Step 1 : Open the official URL : Click me to open
    • Step 2 : Once the setup is downloaded click on .exe setup file
    • Step 3 : Click to accept agreement and follow the recommended steps

4. How to write AutoIT script 

To write an AutoIT script we have to use SciTE Script Editor and for your reference we have mentioned here the syntax of the AutoIT script.

To watch practical demo click on URL : Practical demo of AutoIT

Below script is used for upload the file in web application

Syntax : 
//Sets input focus to a given control on a window.
ControlFocus("Open", "", "Edit1");   
//To enter the filename in search tab
ControlSetText("Open", "", "Edit1", "D:\Practise\Files\UserDetails.xls"); 
//To click on choose button
ControlClick("Open", "", "Button1");

5. How to automate application using AutoIT, Selenium And TestNG

Guys for this point I have written simple code below using AutoIT, Selenium And TestNG
-----------------------------------------------------------
package com.techhelpline.autoitdemo;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.github.bonigarcia.wdm.WebDriverManager;

public class AutoITDemo {
String url = "https://www.remove.bg/";
String autoITScriptPath = "D:\\Practise\\AutoIT\\fileUploadeScript.exe";
WebDriver driver;
ChromeOptions options;

@Test
public void uploadFileUsingAutoIT() throws InterruptedException, IOException {
System.out.println("In file Upload method!!!!");

Thread.sleep(3000);
driver.findElement(
By.xpath("//*[@id='page-content']/section[1]/div[4]/div/div[3]/div[1]/div/div[1]/div[1]/div[2]/button"))
.click();

Thread.sleep(2000);
Runtime.getRuntime().exec(autoITScriptPath);
Thread.sleep(4000);
}

@BeforeClass
public void setup() {
System.out.println("In setup method!!!!!");
WebDriverManager.chromedriver().setup();
options = new ChromeOptions();
options.addArguments("--ignore-certificate-errors");
driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(url);
driver.manage().window().maximize();

}

@AfterClass
public void tearDown() {
System.out.println("In Tear Down Method!!!!");
if (driver != null) {
driver.close();
driver.quit();
}
}
}





          
         
         



Comments

Popular Post

MCQ questions for graphics class method in Java

Session 2 TestNG Framework | How to create TestNG Project In Eclipse IDE | With Selenium Test Cases

Print Hello World In Different Programming Languages | Boost Coding Skill | Developer Life

How to run Selenium script when system is locked?

Read Any Type Of JSON File in JAVA | Simple Introduction And Demo Of JavaScript Object Notation