How to Use Auto It to Upload Files Using Selenium

Upload File in Selenium Webdriver using Autoit

This guide volition show you lot how to Upload File in Selenium Webdriver using Autoit Step by Step guide in a simple manner.

1-While automating web-application many times you will get window-based activity similar- file upload, file download pop-up, window authentication for secure sites, etc. In this case, Selenium will fail and volition non be able to handle desktop elements.

We can upload files in Selenium using different ways

one- Using sendKeys method

two- Using Robot course

three- Using AutoIT

4- Using WGET

Permit me explicate to you the easiest way which works most of the time using sendKeys

Syntax

driver.findElement(By.xpath("xpath of whatsoever chemical element")).sendKeys("File Path");

Example

driver.findElement(By.xpath("//input[@type='file']")).sendKeys("C:\\Downloads\\Mukesh.png");

or

driver.findElement(Past.xpath("//input[@type='file']")).sendKeys("C:/Downloads/Mukesh.png");

Explanation- You do not have to click on file uploader because if you lot click on the file upload push button, it will showtime file uploader which you demand to handle separately.

You lot can find the locator of the chemical element where the file needs to be updated and then you tin pass the file path direct, files can exist excel, png or whatsoever type depends on your application.

Annotation- In case of sendKeys method does not piece of work then you can go ahead with all other options.

Introduction to AutoIT tool

1-AutoIt is a freeware automation tool that can work with desktop applications too.

2-It uses a combination of keystrokes, mouse move and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.1000. VBScript and SendKeys).

For more info about AutoIT, yous can visit their Official WebsiteAutoIt Official Website

Upload File in Selenium Webdriver using Autoit

YouTube video for Same


How to write a script in AutoIT?

For AutoIt scripting, y'all should accept iii things ready.

1-AutoIt Editor- Editor helps us to write AutoIt scripts.

ii-Tool Finder – It will help u.s. to place the chemical element and check their Attributes.

3- AutoIt Help section- This help you to understand about AutoIt functions and what are the parameter it accepts.

Let's showtime with Downloading offset

Pace 1Navigate to AutoIt  official website https://world wide web.autoitscript.com/site/autoit/downloads/ and go to download department or Click here Download AutoIt

Stride two– Click on Download AutoIt and Install

Pace 3–  Click on Download Editor and Install.
Upload File in Selenium Webdriver using Autoit

Step ivOnce both are installed in your machine, check all are installed correctly.

Note- Generally it goes to C:\Program Files\AutoIt3 location if yous do not change it

Upload File in Selenium Webdriver using Autoit

 Step5Open SCiTE folder and  Click on SciTE this will open up AutoIt Editor

Upload File in Selenium Webdriver using Autoit
Once all Installed Allow'south see how we can write the script.

Upload File in Selenium Webdriver using Autoit

To Upload File in Selenium Webdriver using AutoIt we need to take care of some steps so let'southward begin

To upload a file in Selenium Webdriver we volition create AutoIT script, which volition handle file-uploaded window, and and so we will combine Selenium script with AutoIt scripts.

Click on the Upload button you will go a file uploader we volition handle the aforementioned using AutoIt.

Step 1- Open Editor and Finder Tool

Upload File in Selenium Webdriver using Autoit

Upload File in Selenium Webdriver using Autoit

 Stride 2We demand to write script to upload file then we volition use some method of AutoIt.
Each method will have some own functionality
ControlFocus-This will requite focus on the window

ControlSetText-This will gear up the file path

ControlClick-This will click on button

Pace i-

Click on Browse button , a new window will open now open finder tool and Click on Finder tool and drag to the file name as I shown in below screenshot.

Upload File in Selenium Webdriver using Autoit

This will requite all the detail about that window and file name department info; we volition use simply some attributes like window title, class, and instance.

Open up AutoIt Editor and Write Script

Upload File in Selenium Webdriver using Autoit

In ControlClick method, nosotros will give command id of open button

Pace two-

Salve the script to a particular location with some unique name.

Note- Past default script volition be saved as .au3 extension

Step 3– Now Compile the script then for compiling right click on file and Select compile script this volition generate a .exe file of the file.

Upload File in Selenium Webdriver using Autoit
Step four- Now write Selenium plan and add this .exe file and run your program

Here is the code

Thanks for visiting my blog. Please get out a annotate below if you are finding any result while Upload File in Selenium Webdriver using Autoit.

Proceed in touch. Have a prissy day.

Now if you are comfortable with Basic Selenium, you lot can bank check out Advance Selenium Tutorial as well. 🙂

For More updatesLearn Automation page

For whatsoever query bring together Selenium grouping-Selenium Group

hydegare1966.blogspot.com

Source: https://learn-automation.com/upload-file-in-selenium-webdriver-using-autoit/

0 Response to "How to Use Auto It to Upload Files Using Selenium"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel