Use of AutoIT For Uploading The Files


WinWaitActive(“File Upload”)

Send(“D:\test\Selenium\Test.jpg”)

Send(“{ENTER}”)

  • Now save the file as ‘sample’
  • Right click on the saved file >> click ‘Compile script’
  •  ‘sample.exe’ file should be generated.
  • Now to run this .exe file using java, Place this in your code.
  • ‘ Runtime.getRuntime().exec(“D:\\test\\Project\\sample.exe”); ‘
  • Please follow the below example for the reference.

 public class FileUploadAutoIT {

public static WebDriver driver;
String URL = “www.someurl.com";
@Test
public void demoFileUploading() throws InterruptedException, IOException
{
driver = new FirefoxDriver();
driver.get(URL);
WebElement ele = driver.findElement(By.id(“id of attach button”));
ele.click();
Runtime.getRuntime().exec(“D:\\test\\Project\\sample.exe”);
}
}


Disadvantage : 
  • AutoIT supports only for windows.It wont support for ‘mac’

No comments:

Post a Comment

Copyright © 2017 QALEARNINGGUIDE.COM || ALL RIGHTS RESERVED