Java 运行时,在“文件浏览”窗口中选择其他文件
我正在使用SeleniumWeb驱动程序处理文件浏览窗口。在尝试了不同的方法之后,我终于找到了一个使用AutoIt的解决方案 剧本是Java 运行时,在“文件浏览”窗口中选择其他文件,java,selenium,Java,Selenium,我正在使用SeleniumWeb驱动程序处理文件浏览窗口。在尝试了不同的方法之后,我终于找到了一个使用AutoIt的解决方案 剧本是 @Test public void test() throws InterruptedException, IOException { driver.manage().window().maximize(); Thread.sleep(1500); driver.findElement(By.xpa
@Test
public void test() throws InterruptedException, IOException
{
driver.manage().window().maximize();
Thread.sleep(1500);
driver.findElement(By.xpath("//div[@id='input-file-wrapper']")).click();
Thread.sleep(1000);
Process proc =Runtime.getRuntime().exec("D:\\Upload.exe");
driver.findElement(By.xpath("//div[@id='go-btn']")).click();
//driver.findElement(By.name("File name")).sendKeys("D:\\[Limetorrents.cc]_Daawat e Ishq (2014) DvDScr x264 [DTRC] .torrent");
driver.findElement(By.xpath("//div[@id='cloud-free-btn']")).click();
/*
WebDriverWait wait=new WebDriverWait(driver,50);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='vlc- playlist']")));
*/
Thread.sleep(1000);
// String i= driver.findElement(By.xpath("//div[@class='seed-number']")).getText();
boolean i1=driver.findElement(By.xpath("//div[@class='vlc-playlist']")).isDisplayed();
System.out.println(i1);
do
{
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
i1=driver.findElement(By.xpath("//div[@class='vlc-playlist']")).isDisplayed();
}
while(i1!=true);
Thread.sleep(1000);
driver.findElement(By.xpath("//img[@alt='trash']")).click();
driver.findElement(By.xpath("//div[@class='confirm-to-remove']")).click();
}
AutoIt的脚本如下所示,它生成了Upload.exe文件,我在路径名中给出了该文件
WinWaitActive("File Upload")
Send("[kickass.to]desi.kattey.2014.1cd.dvdscr.rip.hindi.xvid.mp3.mafiaking.teamtnt.exclusive.torrent")
Send("{ENTER}")
在这里,每次我运行它时只需要一个文件。如何获取不同的文件。AutoIt脚本提供了从命令行传递参数的功能。因此,当您使用
Runtime.exec(“process”)
执行autoit脚本时,此时将文件名作为参数传递,并接受脚本中的命令行参数。让我知道这是否有帮助