1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
package AutoIt; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Reporter; import org.testng.annotations.Test; /** * * @author PALLLAVI TANDALE * */ /** * UploadFile class * */ package AutoIt; import java.io.IOException; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public class UploadFile{ WebDriver driver; @Test public void testautoit() throws Throwable { System.setProperty("webdriver.chrome.driver","E:\\chromedriver.exe"); driver=new ChromeDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(2000,TimeUnit.SECONDS); driver.get("http://tinyupload.com/"); driver.findElement(By.xpath("//input[@name='uploaded_file']")).click(); //runtime is a class to run Auto IT Script Runtime.getRuntime().exec("C:\\Users\\MAYUR\\Desktop\\AutoIt\\FileUpload.exe"); Thread.sleep(3000); driver.quit(); } } /** * *Auto IT Script */ ControlFocus("Open","","Edit1") Sleep(3000) ControlSetText("Open","","Edit1","C:\Users\MAYUR\Desktop\AutoIt\UploadFile.txt") Sleep(3000) ControlClick("Open","","Button1") |
This code should be generic. file Upload.text is hard coded in the auto it exe file. it should be paramaterized. i.e name and path of the file I should be able to pass from the Java code to the auto it exe file.
Also, provide details about what auto is used, how to create auto it script etc