首先它正在执行else部分,然后在打印println后,它会发出此错误。不知道在退出循环后它是否发生错误。请帮忙。元素不再附加到硒webdriver的DOM错误
Opens a page
Check if the new month is available
Downloads new month ex: Oct
Then comes out of loop and should download Sep
但是在出现循环后它会抛出上面的错误信息。
driver.get("http://www.depreportingservices.state.pa.us/ReportServer/Pages/ReportViewer.aspx?%2fOil_Gas%2fOil_Gas_Well_Historical_Production_Report");
//maximizing the window
driver.manage().window().maximize();
//WebElement select = driver.findElement(By.id("ReportViewerControl_ctl04_ctl03_ddValue"));
// Select select=new Select(select);
List<WebElement> options = driver.findElement(By.id("ReportViewerControl_ctl04_ctl03_ddValue")).findElements(By.tagName("option"));
//List <WebElement> Element1 = new ArrayList<WebElement>() ;
for(WebElement option : options){
if(option.getText().equals("Sep 2015 (Unconventional wells)")) {
driver.get("http://www.depreportingservices.state.pa.us/ReportServer/Pages/ReportViewer.aspx?%2fOil_Gas%2fOil_Gas_Well_Historical_Production_Report");
driver.wait(20000);
//options.wait(10000);
driver.findElement(By.id("ReportViewerControl_ctl04_ctl03_ddValue"));
System.out.println("old month");
break;
}
else {
// if(option.getText().contains("Oct"))
//{
System.out.println("Download new month");
WebElement identifier = driver.findElement(By.xpath(".//*[@id='ReportViewerControl_ctl04_ctl03_ddValue']"));
Select select1 = new Select(identifier);
//select1.selectByVisibleText("Oct");
select1.selectByVisibleText("Oct 2015 (Unconventional wells)");
Wait(20000);
driver.findElement(By.xpath(".//*[@id='ReportViewerControl_ctl04_ctl00']")).click();
Wait(70000);
//Click on File save button
driver.findElement(By.xpath(".//*[@id='ReportViewerControl_ctl05_ctl04_ctl00_Button']")).click();
//wait time to load the options
Wait(20000);
driver.findElement(By.xpath(".//*[@id='ReportViewerControl_ctl05_ctl04_ctl00_Menu']/div[2]/a")).click();
//fprofile.setPreference("browser.download.manager.showWhenStarting", false);
//fprofile.setPreference("pdfjs.disabled", true);
Wait(10000);
// driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println("Oct month data downloaded in csv format");
//driver.navigate().back();
}
我可以知道如何克服呢? – user2762008
我编辑了我的答案。 – Guy
我认为一个新的页面正在被打开,当你正在下载文件,这是从'DOM'删除'选项' – Paras