Single Post

Header

Sunday, November 1, 2015

File Upload using Selenium WebDriver and Auto it scripts

File Upload using Selenium WebDriver and Auto it scripts

import java.io.IOException;

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

public class FileUpload {

@Test
public void fileUpLoad() throws InterruptedException, IOException {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.sendspace.com/");
Thread.sleep(3000);
driver.findElement(By.id("upload_file")).click();
Runtime.getRuntime().exec("E:\\Selenium\\fileUpload.exe"); 
driver.close();
}

}

Auto it script : File name given as - fileUpload.au3.  
Right click on the file and click on compile script. Generates fileUpload.exe file

WinWaitActive("File Upload")
Send("E:\Selenium\testFile.txt")
ControlClick("", "&Open", "Button1")

No comments:

Post a Comment