05 AutoIT

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Mind Q Selenium

AutoIT
Selenium designed to automate web-based applications on different browsers but it
is not able to handle window GUI popups in application.
ex: upload file, print popup...etc.
AutoIT v3 is also freeware. It is used to perform mouse movement, keystrokes and
window control manipulation to automate a task which is not possible by selenium
webdriver.
upload/download a file in selenium webdriver using AutoIT we need three tools in
order to this.
1. Selenium Webdriver
2. AutoIT editor
3. Element identifier
1. Selenium WebDriver
which is already we converd in previous concepts
2. AutoIT Editor:
It is a freeware BASIC-like scripting language designed for automating the
Windows GUI and general scripting.
Download and install AutoIT:
Download and install AutoIT:
Enter "https://www.autoitscript.com/site/autoit/downloads"

Click on 'AutoIT' Downloads option


Download "AutoIT" by clicking on 'Download AutoIT' button
Install AutoIT
Now download "AutoIT editor" by clicking on

Scenario: upload a file in Timesjobs.com


Upload file in Selenium using AutoIt
Uploading of file is a four steps process:
Step 1: Identify the Window controls
Step 2: Build a AutoIt script using identified windows control

69
Mind Q Selenium

Step 3: Compile the .au3 script and convert it into .exe file
Step 4: Call the .exe file in to the Selenium test case
Step 1: Identify the Window Controls:
use "AutoIt Window Info" to find object information
Now drag the ‘Finder Tool‘ box to the object in which you are interested

Step 2: Build an AutoIt script using identified windows control


SciTE Script Editor:
It is used to develop scripts and it offers certain really useful features such as
syntax highlighting, code folding, auto complete, etc., and effective to build/write
descriptive scripts using different control parameters and execution logics
Navigation:
Start-->all programs-->in the auto it-->SciTEScriptEditor -->we can write
the script

Or
WinWaitActive ("File Upload")
ControlFocus("[CLASS:#32770]", "", "Edit1")

70
Mind Q Selenium

Send ("E:\Profile_SankaR.docx")
Send ("{Enter}")
or
WinWaitActive ("File Upload")
Send ("E:\Profile_SankaR.docx")
Send ("{Enter}")
-->Save the script (it will save as filename.au3)
Step 3: Compile the .au3 script and convert it into .exe file
go to the folder containing the file-->right click on the file-->compile it [Will create
filename.exe]

Step 4: Call the .exe file in to the Selenium test case


To run any exe file [Runtime.getRuntime ().exec ("path of .exe");]
Ex:
Runtime.getRuntime().exec("E:\\upload.exe");
Examples:
ex: Create script to download the file
Script in Eclipse:
WebDriver driver= new FirefoxDriver();
driver.get("http://www.seleniumhq.org/download/");
driver.manage().window().maximize();

driver.findElement(By.linkText("64 bit Windows IE")).click();


Thread.sleep(3000);
Runtime.getRuntime().exec("E:\\DownloadAutoIt.exe");
AutoIt Script:
;to focus on window
WinWaitActive("Opening IEDriverServer_x64_3.8.0.zip")
71
Mind Q Selenium

;to click on Enter button


Send ("{Enter}")
ex:
Ex: Create script to upload file using AutoIT in www.sendfiles.net page
Procedure:
step 1: create script in Eclipse to open application and to upload file
script:
WebDriver driver= new FirefoxDriver();
driver.get("https://www.sendfiles.net/");
driver.manage().window().maximize();

driver.findElement(By.linkText("START NOW")).click();
driver.findElement(By.xpath("//*[text()='Add Files']")).click();

Step 2: create script in AutoIT Editor


Script:
;to wait until popup window to activate
WinWaitActive("File Upload")
;to enter file path
ControlSetText("File Upload","","Edit1","E:\Madhukar.docx")
;to pause execution
Sleep(2000)
;to click on open
ControlClick("File Upload","","Button1")

Step 3: save autoIT Editor script and compile


Navigation:
select AutoIT file (.au3)
right click on mouse
select "compile (64/86)"
step 4: run .exe file of AutoIT script by calling into Eclipse
syntax:
Runtime.getRuntime().exec(path of .exe file);

72

You might also like