Before Using AutoIt first you have to know few things about autoit.
Three simple steps we have to follow always When we are using auto it.ControlFocus-This will give focus on the window
ControlSetText-This will set the file path
ControlClick-This will click on button
1. Select the window and get the focus on it.
2. Type the file name with path in the text box.
3. Click open button, so that all the selection details are transferred into web page control and
selenium can take control of the next activity.
Scenario for uploading file using Auto it.
1.Go to
http://api.checklist.com/login
2.Enter Email as rgulati883@gmail.com
3.Enter Password as jaiguruji
4.Click on Login
5.Click on Checklist1
6.Click on upload
7.Then add path of your File
8.Click on open button.
9.File Added
9.File Added
1.Enter email= rgulati883@gmail.com
2.Enter password = jaiguruji
3.Click on Login
4.Click on Checklist1(0)
5.Go to that path Where your AutoIt is Downloaded>Click on AutoIt
6.Click on AutoIt.You will get this Finder Tool
7.Click on Upload
8.Browser window will open
9.Drag this FinderTool to Filename Textbox
10.Note Title of Window = Open
11.Class = Edit
12.Instance = 1
ControlID = Class+Instance
13.Click on ScITE and Write a Smal Script into that
14.Write a small script into it.Make sure in Google chrome Browser Title of window is (open)
Title of Window in Mozilla Browser is (File Upload).
15. ControFocus("TitleofWindow","","Class+Instance")
ControFocus("Open","","Edit1")
16.ControlSetText("TitleofWindow","","Class+Instance","Path of Your File")
ControlSetText("Open","","Edit1","Path of Your File")
17.After adding path we Have to Click Open Button for Uploading File
18. Drag the Finder tool to the Open Button
19. ControlClick("Title of window","","ControId")
ControlClick("Open","","Button1")
20. Save the script to a location.Script will be save as .au3 extension.After saving you will get this 

21.After saving it compile this script. Rightclick>Compilescript
22. After compiling you will get this
23. Now copy the path of this file. ("C:\\Users\\Hp\\Desktop\\tesing.exe").
24. Now write Selenium program and add this .exe file and run your program.
package test;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class TestFileUpload2 {
public static void main(String[] args) throws InterruptedException, IOException {
WebDriver driver = new FirefoxDriver();
driver.get("http://api.checklist.com/login");
driver.findElement(By.xpath("//*[@id='email']")).sendKeys("rgulati883@gmail.com");
driver.findElement(By.xpath("//*[@id='loginForm']/div[2]/input")).sendKeys("jaiguruji");
driver.findElement(By.xpath("//button[@class='btn btn btn-primary pull-right']")).click();
Thread.sleep(8000);
driver.findElement(By.xpath("//*[@id='userChecklists']/li[1]/a/span")).click();
WebElement UploadImg = driver.findElement(By.xpath("//*[@id='taskUploadFile']"));
UploadImg.click();
Runtime.getRuntime().exec("C:\\Users\\Hp\\Desktop\\tesing.exe");
Thread.sleep(2000);
}
}























The blog gave me idea to upload file using auto IT Thanks for sharing it
ReplyDeleteSelenium Training in Chennai
really you have posted an informative blog. it will be really helpful to many peoples. so keep on sharing this kind of an interesting blogs.
ReplyDeleteselenium training in chennai