我正在尝试浏览带有嵌套框架的页面.页面结构如下:
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.以下代码可以正常运行,可以找到正确的链接,但是以某种方式click()调用不会产生任何效果,并且内容也不会加载到内部框架中.
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.
更多推荐
无法在嵌套框架中使用硒单击
发布评论