Selenium WebDriver File Upload AutoIt
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class UploaderTest {
public static void main(String[] args) throws IOException, InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://tinypic.com/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
//driver.findElement(By.xpath("//*[@id='the_file']")).sendKeys
("C:\\Users\\SPA\\Desktop\\resume.txt");
//AutoIt
driver.findElement(By.xpath("//*[@id='the_file']")).click();
Thread.sleep(5000);
Runtime.getRuntime().exec("C:\\Users\\SPA\\Desktop\\AutoItScript.exe");
}
}
| This video will tell all ways to upload file/document using Selenium WebDriver. Also covered uploading file using AutoIT and Selenium. |
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class UploaderTest {
public static void main(String[] args) throws IOException, InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://tinypic.com/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
//driver.findElement(By.xpath("//*[@id='the_file']")).sendKeys
("C:\\Users\\SPA\\Desktop\\resume.txt");
//AutoIt
driver.findElement(By.xpath("//*[@id='the_file']")).click();
Thread.sleep(5000);
Runtime.getRuntime().exec("C:\\Users\\SPA\\Desktop\\AutoItScript.exe");
}
}
============================Auto IT======================================
ControlFocus("File Upload","","Edit1")
ControlSetText("File Upload","","Edit1","C:\Users\SPA\Desktop\resume.txt")
ControlClick("File Upload","","Button1")
ControlFocus("File Upload","","Edit1")
ControlSetText("File Upload","","Edit1","C:\Users\SPA\Desktop\resume.txt")
ControlClick("File Upload","","Button1")
I joined with them for selenium training and it’s going on good.
ReplyDeleteHope I will be placed in a good company.
They are cool team so far in chennai .
Call them at 8122241286.
www.thecreatingexperts.com
selenium training in chennai
I strongly recommend them for Appium training in Chennai.
ReplyDeleteCall at 8122241286.
www.thecreatingexperts.com
Appium training in chennai