Java 在IE上测试时无法切换到框架,但在chrome上工作正常

Java 在IE上测试时无法切换到框架,但在chrome上工作正常,java,selenium,testng,Java,Selenium,Testng,我能够切换到框架,能够在镀铬的情况下定位元素,但在IE的情况下无法定位 driver.switchTo().frame(0); driver.findElement(By.xpath("//a[contains(.,'Logout')]")).submit(); 使用这两行代码可以访问,但我认为在IE的情况下它不能在框架中切换。我尝试通过WebElement、索引和名称切换框架 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transiti

我能够切换到框架,能够在镀铬的情况下定位元素,但在IE的情况下无法定位

driver.switchTo().frame(0);  
driver.findElement(By.xpath("//a[contains(.,'Logout')]")).submit();
使用这两行代码可以访问,但我认为在IE的情况下它不能在框架中切换。我尝试通过
WebElement
、索引和名称切换框架

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<frameset id="frRoot" framespacing="0" border="0" frameborder="0" rows="125,26,*,0,0">
<frame id="frTopLeftPane" scrolling="no" name="brandingTop" src="/BIW/Lobby/Frameset/BrandingTop.aspx?dv=1&amp;nfGuid=">

<a style="vertical-align:top;" href="/ic/bin/logout.asp? 
sessionid=&amp;id=338206" target="_top">

<img src="/skins/BIW/NewSkin/images/logout.gif" alt=""> Logout
                    </a>
 </frame>
</frameset>
</html>

您应该真正升级您的代码,并引入webDriverWait以提高稳定性。请尝试下面给出的代码:

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("frRoot")));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("frTopLeftPane")));
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(.,'Logout')]"))).submit();

您看到了什么错误?执行JavaScriptIt时出错根本不起作用,给出错误信息:HTTP状态:“404”->“没有这样的帧”的JSON状态映射不正确(预期为400)删除此行
wait.until(ExpectedConditions.FrameToBeAvailable和SwitchToIt(By.id(“frRoot”)