package Test;
import java.io.File;
import java.io.IOException;
import java.sql.Time;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.testng.annotations.Test;
import org.testng.annotations.Test;
public class File upload {
private Process process;
@Test
public void run() throws IOException, InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\gwda\\Desktop\\chromedriver.exe");
WebDriver s1 = new ChromeDriver();
s1.get("Enter your URL");
s1.manage().window().maximize();
s1.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS );
s1.findElement(By.id("mainUserName")).sendKeys("username");
s1.findElement(By.id("mainPassword")).sendKeys("password");
s1.findElement(By.xpath("//input[@src='images/ButtonSignIn.png']")).click();
Thread.sleep(3000);
s1.findElement(By.xpath("//ul[1]/li[3]/a[contains(text(),'File Upload')]")).click();
s1.findElement(By.xpath("//input[@id='uploadfile']")).click();
process = new ProcessBuilder("C:\\Users\\gwda\\Desktop\\file1.exe",
"C:\\Users\\gwda\\Desktop\\PartListLoader.txt","Open").start();
Thread.sleep(3000);
s1.findElement(By.xpath("//input[@id='fileRead_fileTypeTab Delimited Text File(.txt) ']")).click();
Thread.sleep(3000);
s1.findElement(By.xpath("//span[@id='loadList']")).click();
Thread.sleep(3000);
s1.findElement(By.xpath("//span[contains(text(),'Yes')]")).click();
Thread.sleep(3000);
File scrFile3 = ((TakesScreenshot)s1).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile3, new File("c:\\tmp\\k1.png"));
}
}
import java.io.File;
import java.io.IOException;
import java.sql.Time;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.testng.annotations.Test;
import org.testng.annotations.Test;
public class File upload {
private Process process;
@Test
public void run() throws IOException, InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\gwda\\Desktop\\chromedriver.exe");
WebDriver s1 = new ChromeDriver();
s1.get("Enter your URL");
s1.manage().window().maximize();
s1.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS );
s1.findElement(By.id("mainUserName")).sendKeys("username");
s1.findElement(By.id("mainPassword")).sendKeys("password");
s1.findElement(By.xpath("//input[@src='images/ButtonSignIn.png']")).click();
Thread.sleep(3000);
s1.findElement(By.xpath("//ul[1]/li[3]/a[contains(text(),'File Upload')]")).click();
s1.findElement(By.xpath("//input[@id='uploadfile']")).click();
process = new ProcessBuilder("C:\\Users\\gwda\\Desktop\\file1.exe",
"C:\\Users\\gwda\\Desktop\\PartListLoader.txt","Open").start();
Thread.sleep(3000);
s1.findElement(By.xpath("//input[@id='fileRead_fileTypeTab Delimited Text File(.txt) ']")).click();
Thread.sleep(3000);
s1.findElement(By.xpath("//span[@id='loadList']")).click();
Thread.sleep(3000);
s1.findElement(By.xpath("//span[contains(text(),'Yes')]")).click();
Thread.sleep(3000);
File scrFile3 = ((TakesScreenshot)s1).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile3, new File("c:\\tmp\\k1.png"));
}
}
No comments:
Post a Comment