【发布时间】:2011-11-26 09:52:06
【问题描述】:
我有一个 iframe,当我单击页面上的选项卡时会加载该 iframe。当我使用 Firebug 查看 IE8 上的 iframe 时,我看到的只是:
iframe id=tabContextFrame class=contextFrame contentEditable=inherit src=/xyz.dt?forward=show&layouttype=NoHeader&runid=1234 name=tabContextFrame url=/xyz.dt?forward=show&layouttype=NoHeader&runid=1234 scrolling=auto
就是这样。无法看到 iframe 下方的层次结构。我想点击 iframe 中的链接。为了在 iframe 中查找元素,我执行了 selenium.click("on the tab that loads the iframe") 和 selenium.getHtmlSource()。从这个来源,我至少可以找到我感兴趣的链接。我做了一个selenium.click("//span[text()='Link']"),但它似乎没有做任何事情。请问有什么想法吗?
代码如下:
selenium.click("//span[text()='tab that loads iframe']");
Thread.sleep(5000);
selenium.selectFrame("tabContextFrame");
selenium.mouseOver("//span[text()='Link']");
selenium.mouseDown("//span[text()='Link']");
selenium.mouseUp("//span[text()='Link']");
Thread.sleep(5000);
selenium.selectFrame("null");
【问题讨论】:
-
您是否尝试过使用 web 驱动程序的 selenium 2.0?你可以使用 driver.SwitchTo().Frame()