2017-08-28 42 views
0

我目前正在测试脚本,需要上传到文件并检查文件上传是否成功。我能够成功上传第一个文件,因为它是一个非常小的文件(7KB)。尝试上传大文件时的网络驱动程序超时

但是,当我尝试上传第二个相对较大(8 MB)的文件作为测试环境时。该守则超时而不继续下一步。

我试着用这无助于解决问题

WebElement filePath2 = driver.findElement(By.xpath(".//*[@id='wrapper']/table[2]/tbody/tr[1]/td/table/tbody/ tr[4]/td[2]/form/input[6]")); 

filePath2.sendKeys("\\\\this\\is\\a\\sample\\file\\path\\SAMPLEFILE_LARGE.txt"); 

driver.findElement(By.xpath(".//*[@id='wrapper']/table[2]/tbody/tr[1]/td/table/tbody/tr[4]/td[2]/form/input[7]")).click(); 

//Used below waits separaytly, but did not work out 

//Thread.sleep(300000); 
WebDriverWait wait1 = new WebDriverWait(driver,300); 

boolean upload = driver.getPageSource().contains("SAMPLE FILE LARGE"); 
if (upload == true){ 
    System.out.println("Large file uploaded successfully"); 
} 
else{ 
    System.out.println("Large file DID NOT upload successfully, Exiting automation now."); 
} 
+0

文件上传后会发生什么,不文件名出现在任何地方,或者文件上传成功的任何其他指示? – smit9234

+0

如果您手动上传大文件,需要多长时间? –

+0

你得到的错误/异常是什么? –

回答

0

您可以使用Thread.sleep(50000);等待语句等待50秒或者近似为下道工序

+0

我等了Thread.sleep(300000); 5分钟,但仍然出错 – johnsonambrose

+0

基本上需要多少时间完成上传? – zsbappa

+0

当我尝试手动运行脚本时,花了4分30秒。我能够手动上传文件。但是,即使等待5分钟后,程序也会超时。 – johnsonambrose