123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computers >> View Article

Traditional Tool To Use Windows Based Gui During Automation

Profile Picture
By Author: Fleek IT Solutions
Total Articles: 45
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

AutoIT tool

AutoIt is an automation tool which is used for automating windows GUI. AutoIt is a third-generation programming language with various data types which can store several types of data.
So, selenium you can use only for browser or HTML component. If you have any need to do automation or anything outside the browser you can use some other tool and AutoID is one of them.

An AutoIt automation script can be converted into a compressed, stand-alone exe file and this is something that we can use and call our selenium script.

AutoIt is having 2 components:
1) AutoIT - Identify elements on the window.
2) AutoIt Editor(SciTE) - editor to write autoIT script

When to use AutoIt with selenium:

Selenium can not handle anything which is outside the browser or non HTML elements. In real world, you will encounter situation where you have to do a file upload or something eject with a windows authentication box or any other non-browser interaction in those situations selenium will not help, you will need to help from external source i.e AutoIT

AutoIt has built-in features to ...
... compile script and do not need any extra add-on to do all things. When we need some popup or download something it won't be able to identify the window based object.


AutoIt with selenium:

1) Download and install autoIT
2) Download AutoIT ScriptEditor(SciTE)
3) Open Au3info.exe and locate objects on the windows GUI
4) create AutoIT Script and Test
5) Call AutoIT scripts in Selenium Test

Steps to integrate AutoIT

1) Write AutoIT scripts for file uploading (AutoIT Editor).
ControlFocus() -> focus on the text box
ControlSetText -> providing a path for a file.
ControlClick() -> clicking on open button
AutoIT Scripts:

ControlFocus("Open","","Edit1")
Sleep(3000)
ControlSetText("Open","","Edit1","D:\Fleek\File.txt")
Sleep(3000)
ControlClick("Open","","Button1")


2) Compile AutoIT scripts and generate .exe file.

Tool -> Compile -> Select x64 -> Click Compile Script -> generated.exe file.

3) Use .exe file in selenium webdriver script.

To Upload file using AutoIT

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class AutoIT
{
public static void main(String[] args) throws Exception {

System.setProperty("webdriver.chrome.driver", "chrome driver path");
WebDriver obj1 = new ChromeDriver();
obj1.get("URL");
obj1.manage().window().maximize();
// Actions builder= new Actions(obj1);
// WebElement mouse= obj1.findElement(By.xpath("//b[contains(text(),'Start')]"));
// builder.moveToElement(mouse).perform();
obj1.findElement(By.xpath("//input[@name='uploaded_file']")).click();

Thread.sleep(2000);
Runtime.getRuntime().exec("path\\Filescript.exe");
}
}


To show the popup window.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Auto_notepad {
public static void main(String[] args) throws Exception
{
System.setProperty("webdriver.chrome.driver", "chrome driver path");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("URL");
//Download Text File
driver.findElement(By.xpath("//a[contains(text(),'Download Text File')]")).click();
Runtime.getRuntime().exec("path\\download.exe");
driver.close();
}
}

AutoIT Script for Save notepad file or Replace file:

ControlFocus("Run","","Edit1")
Sleep(2000)
ControlSetText("Run","","Edit1","notepad.exe")
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Fleek IT Solutions")
WinMenuSelectItem("*Untitled - Notepad","","&File","&Save")
WinWaitActive("Save As")
ControlFocus("Save As","","Edit1")
ControlSend("Save As","","Edit1","file12.txt")
Sleep(2000)
ControlClick("Save As","","Button2")

if WinWaitActive("Confirm Save As") Then
ControlClick("Confirm Save As","","Button2")
WinWaitActive("Save As")
ControlSend("Save As","","Edit1","file13.txt")
ControlClick("Save As","","Button2")
Else
WinWaitActive("file13 - Notepad")
WinClose("file13 - Notepad")
EndIf

Total Views: 366Word Count: 569See All articles From Author

Add Comment

Computers Articles

1. Devopsin Hallinnoimat Palvelut: Tietoturva Ja Tiedon Hallinta
Author: harju

2. Hyödynnä Pilvesi Täysi Potentiaali Google Cloud Monitoring Solutions -ratkaisuilla
Author: harju

3. Pysy Kyberuhkien Edellä Google Cloud Security Services -palvelun Avulla
Author: harju

4. Mullista Yrityksesi Nopeilla Ja Turvallisilla Googlen Pilvipalveluratkaisuilla
Author: harju

5. Googlen Pilvi-identiteetin Hallintapalvelut Pienille Ja Keskisuurille Yrityksille
Author: harju

6. Google Cloud -konsultointi: Tukea, Strategiaa Ja Kehitystä Yrityksellesi
Author: harju

7. Iot Edge -laskentapalvelut Ja Ai – Älykkään Datankäsittelyn Tulevaisuus
Author: harju

8. Älykäs Reunalaskenta: Tehokkuutta Ja Kilpailuetua Yrityksellesi
Author: harju

9. Cloud Change -palvelut – Tulevaisuuden It-ratkaisu Liiketoiminnallesi
Author: harju

10. Aws-tietokannan Siirtopalvelu Ja Hybridiympäristöt – Miten Ne Toimivat Yhdessä?
Author: harju

11. What Makes Google Ads Management Services Better Than Other Digital Marketing Campaigns?
Author: Digital Agency

12. Things You Should Know About Nema And International Plug Adapters
Author: Jennifer Truong

13. The Best 8 Tools For Data Analysis
Author: goodcoders

14. Top 5 Customer Experience Management Problems And Solution
Author: goodcoders

15. How To Create A Framework-agnostic Application In Php?
Author: goodcoders

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: