Upload Multiple Files using Auto IT in Selenium - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Tuesday, 6 February 2018

Upload Multiple Files using Auto IT in Selenium



Below is the AUTO It Script for Mutiple Files

$vVariable = """C:\Users\NEERAJ\Desktop\Manage_Plugins.jpg"" ""C:\Users\NEERAJ\Desktop\Manage_Plugins1.jpg"""

ControlFocus("File Upload","","Edit1")
Sleep(2000)
Sleep(2000)
ControlSetText("File Upload", "", "Edit1" ,$vVariable)
Sleep(2000)



ControlClick("File Upload", "", "Button1")


Note:Here we are using double quotes , because when we upload multiple files the files are seperated with double quotes.

Example: " "filename1" "filename2" "
Refer below Screenshot





Refer Below Working Script


package mypackage;

import java.io.IOException;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class myclass {
public static void main(String[] args) throws IOException, InterruptedException {
WebDriver driver = new FirefoxDriver();
String baseUrl = "https://davidwalsh.name/demo/multiple-file-upload.php";
driver.get(baseUrl);

driver.findElement(By.xpath(".//*[@id='filesToUpload']")).click();
Thread.sleep(4000);

Runtime.getRuntime().exec("C:\\Users\\NEERAJ\\Desktop\\NewUpload.exe");
}
}

No comments:

Post a Comment