首先它正在執行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