Java Selenium无法识别新打开的窗口
大家好,我有麻烦了。我的测试单击hyperlynk,将显示一个新窗口。问题是,当我实现windows处理程序时,selenium只识别一个窗口而不是两个窗口,并且当我尝试查找窗口的元素时,我不能因为selenium而导致窗口不存在:Java Selenium无法识别新打开的窗口,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,大家好,我有麻烦了。我的测试单击hyperlynk,将显示一个新窗口。问题是,当我实现windows处理程序时,selenium只识别一个窗口而不是两个窗口,并且当我尝试查找窗口的元素时,我不能因为selenium而导致窗口不存在: driver.switchTo().frame(CQLo.getMframe()); WebElement Rad_CIT = (new WebDriverWait(driver,10)).until(ExpectedConditions.element
driver.switchTo().frame(CQLo.getMframe());
WebElement Rad_CIT = (new WebDriverWait(driver,10)).until(ExpectedConditions.elementToBeClickable(CQLo.getRadCIT()));
Rad_CIT.click();
WebElement Text_CIT = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(CQLo.getTextCIT()));
Text_CIT.clear();
Text_CIT.sendKeys(citbox);
setLog("CITBox: " +citbox);
//WebElement Link_WFM =
Actions act = new Actions(driver);
WebElement onElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(CQLo.getLink_WFM_Admin()));
act.contextClick(onElement).perform();
act.sendKeys("o").perform();
Set <String> wind_ows = driver.getWindowHandles();
for(String sw : wind_ows)
{ System.out.println(""+sw.toString());}
setLog("Open log on " +citbox);
Thread.sleep(2000);
WebElement Text_UserN = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(Elog.getUserName()));
Text_UserN.sendKeys(MSR_name);
WebElement Text_UserP = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(Elog.getUserPassword()));
Text_UserP.sendKeys(MSR_pass);
WebElement B_logon = (new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable(Elog.getB_logon()));
B_logon.click();
在使用窗口打印集合后,我只收到一个窗口请等待一段时间,然后在执行单击元素后获取窗口句柄。我想当你阅读驱动程序窗口句柄时,新窗口可能无法打开 分享一些到目前为止您尝试过的代码,我们可以帮助您