无法在嵌套框架中使用硒单击

编程入门 行业动态 更新时间:2024-10-27 10:31:20
本文介绍了无法在嵌套框架中使用硒单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试浏览带有嵌套框架的页面.页面结构如下:

I am trying to navigate on a page with nested frames. The page structure looks like this:

<frameset name="framesetContainer"> <frame name="WebTopMenu"> ... </frame> <frame name="WebContent"> <frameset name="framesetTopContainer"> <frameset name="framesetWSTopMenu"> <frame name="frameTitle"> ... </frame> <frame name="frameTopMenu"> ... </frame> </frameset> <frameset name="framesetLeftMenuContentContainer"> <frameset name="framesetLeftMenuContainer"> ... </frameset> <frame name="frameContent"> ... </frame> </frameset> </frameset> </frame> </frameset>

要导航的链接位于 frameTopMenu 框架中,并将内容加载到 frameContent 中.

The links to navigate reside in the frameTopMenu frame and the content is loaded into frameContent.

我正在使用Selenium(2.35.0)的WebDriver API.以下代码可以正常运行,可以找到正确的链接,但是以某种方式c​​lick()调用不会产生任何效果,并且内容也不会加载到内部框架中.

I am using the WebDriver API of Selenium (2.35.0). The following code runs fine without any exception, it finds the correct link but somehow the click() call does not have any effect and the content is not loaded into the inner frame.

driver.switchTo().frame("WebContent").switchTo().frame("frameTopMenu"); driver.findElement(By.id("link01")).click();

我想念什么吗?

不幸的是,无法更改框架结构.

推荐答案

切换到任何框架元素,只需使用driver.switchTo().frame("framename");

switch to any frame element , just use driver.switchTo().frame("framename");

一旦切换到一帧,如果需要切换到另一帧,就必须切换到父帧.

Once we switched to one frame, if we need to switch to another frame, we have to switch to the parent frame.For that use

driver.switchTo().parentFrame();

driver.switchTo().parentFrame();

如果使用driver.switchTo().defaultContent();,则可能不起作用.因此,选择driver.switchTo().parentFrame();即可.

If you use driver.switchTo().defaultContent();, it may not work. so go for driver.switchTo().parentFrame();, it works fine.

更多推荐

无法在嵌套框架中使用硒单击

本文发布于:2023-11-27 20:40:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639522.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   单击   框架

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!