Selenium 我无法使用Internet Explorer切换到IFrame
我开发了一个s关键字驱动的框架。它有一个动作关键字来切换帧。 它可以与Mozilla配合使用。但当涉及到IE时,它并没有改变。它记录错误。 IE驱动程序-IEDriverServer_x64_2.44.0 IE版本-9 Selenium版本-Selenium-java-2.44.0 提前谢谢Selenium 我无法使用Internet Explorer切换到IFrame,selenium,selenium-webdriver,internet-explorer-8,Selenium,Selenium Webdriver,Internet Explorer 8,我开发了一个s关键字驱动的框架。它有一个动作关键字来切换帧。 它可以与Mozilla配合使用。但当涉及到IE时,它并没有改变。它记录错误。 IE驱动程序-IEDriverServer_x64_2.44.0 IE版本-9 Selenium版本-Selenium-java-2.44.0 提前谢谢 public static void switchFrame(String object,String data)throws Exception{ try{ driver.
public static void switchFrame(String object,String data)throws Exception{
try{
driver.switchTo().frame("Ifrm");
Log.info("Switched the frame");
}
catch(Exception e){
Log.error("Not able to switch the frame--- " + e.getMessage());
DriverScript.bResult = false;
}
}
这里出现异常。我假设,您在frame中指定的值是id/name/etc。您必须通过调用具有指定值的驱动程序来访问frame。代码是
driver.switchTo().frame(driver.findElement(By.id("Ifrm")));
Selenium不允许我在InternetExplorer上按ID切换到iframe,但它允许我按索引切换。如果您有某种类型的属性,您可以检查它是否仅在iframe上可用,您可以执行以下操作
new WebDriverWait(driver, 5).until(
new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
try {
int i = 1;
while (true) {
driver.switchTo().defaultContent();
driver.switchTo().frame(i);
String aClass =
driver.findElement(By.xpath("/html/body"))
.getAttribute("class");
if (aClass.contains("modal")) {
return true;
}
++i;
}
} catch (NoSuchFrameException e) {
return false;
}
}
}
);
在我的例子中,我正在寻找一个modal的body类你能发布它抛出错误的代码和行吗?2015-02-27 16:44:22954 error[Log]无法切换框架--无法找到id==Ifrm的元素警告:服务器未提供任何stacktrace信息问题。您可以在IE和Firefox中发布HTML代码或屏幕截图吗。IE和Firefox之间的框架名称可能不同。同时比较IE和Firefox的DOM结构。IE中可能会有额外的框架。如果指定的话,网站是否可以公开访问。我会试试。否。你能提供你的邮件ID吗?我想你可以在这里添加截图/附件。希望这不是违反共享电子邮件id的政策。我的电子邮件id是visitjaga@gmail.com。似乎仍然失败,您可以按数字ID切换,但不能按WebElement或ID名称切换