java - 在 IE 上测试时无法单击元素
问题描述
下面的代码在 chrome 中运行良好,能够切换到框架并单击注销按钮。但是在 IE 的情况下,它显示“无法单击元素错误”。而不是(.click())我使用(.submit())然后它会给出错误,如“执行 javascript 时出错”。
driver.switchTo().frame("brandingTop");
driver.findElement(By.xpath("//a[contains(.,'Logout')]")).click();
<html>
<head><title>Software Testing Help - iframe session</title>
</head>
<body>
<frameset id="frRoot" framespacing="0" border="0" frameborder="0" rows="125,26,*,0,0">
<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&nfGuid=">
<a style="vertical-align:top;" href="/ic/bin/logout.asp?sessionid=&id=338206" target="_top">
<img src="/skins/BIW/NewSkin/images/logout.gif" alt=""> Logout
</a>
</frame>
</frameset>
</frameset>
</frameset>
</body>
System.setProperty("webdriver.ie.driver",AbsoluteDriverPath);
webdriver=new InternetExplorerDriver();
webdriver.get(URL);
webdriver.manage().window().maximize();
webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.switchTo().frame("brandingTop");
driver.findElement(By.xpath("//a[contains(.,'Logout')]")).click();
解决方案
尝试使用框架元素本身而不是名称来切换框架。
frameElement = driver.findElement(By.xpath("//frame[contains(@name,'brandingTop')]"));
driver.switchTo().frame(frameElement);
推荐阅读
- c++ - 使用大型链接库调试应用程序需要大量时间
- kubernetes-metrics - k8s metric server api结果中的“窗口”是什么意思
- rust - Rust:打印作为参数传入的函数的名称
- iis - Firefox 错误“此页面的某些部分不安全(例如图像)”RDS 2016
- python-3.x - Python 使用 xpath 从 HTML 中提取内容
- java - 刷新部署在 Kubernetes 集群中多个 Pod 上的 Spring Boot 应用程序实例中的 bean
- r - 在 R 中,'waiver()' 的功能是什么?
- python - jupyter notebook 上的 Turicreate 无法识别
- flutter - 在颤振中检查连接并根据连接状态更改状态
- google-directions-api - 将请求路线航点与响应匹配