html - Watir/Selenium2 在 Internet Explorer 9 中单击 iframe 内的元素后没有任何反应

标签 html ruby watir-webdriver selenium-webdriver

我正在 Ubuntu 上使用 Watir-WebDriver 和 Ruby 1.9.2 为网络编写自动测试。我有一些带有几个元素的 iframe。我需要单击项目并检查会发生什么。 <iframe>看起来像:

<iframe id="iframe" align="top" some_attribute="some_attribute">
    <html>
        <head>
            <title> Some title </title>
        </head>
        <body>
            <div>
                <button id="id_button" type="button" class="some_class"/>
            </div>
        </body>
    </html>
</iframe>

当我点击按钮时,它应该创建菜单。但是当我点击带有 watir-webdriver 的按钮时,没有任何反应,就好像他没有按下一样。 Watir 不打印任何异常,但不按下按钮。

此问题仅存在于 Internet Explorer 中。对于 Firefox 和 Chrome,没有问题。我的代码如下所示:

browser = Watir :: Browser.new (: remote,: url => "http://some_ip:4444/wd/hub",: desired_capabilities =>: internet_explorer)
browser.goto ("http://some_http.com")
browser.iframe.button (: id, "id_button"). click

如果我写

browser.iframe.button(: id, "id_button").attribute_value("class") 

它正在返回 "some_class" .这表明该项目已被识别,但仍然没有任何反应。

最佳答案

请试试这段代码

browser.iframe(:id, "iframe").button (: id, "id_button").click

如果您需要更多信息,请查看此链接

http://wiki.openqa.org/display/WTR/Frames

关于html - Watir/Selenium2 在 Internet Explorer 9 中单击 iframe 内的元素后没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12306297/

相关文章:

ruby - Mailchimp 订阅元数据

ruby - 使用 Watir 进行 Gmail 注册访问网页元素

ruby-on-rails-3 - 将 watir 与 headless 结合使用时,Windows 上出现 Xvfb 错误

javascript - 关于 iPhone 旋转时 HTML 的问题

Ruby Net::HTTP 不解码 gzip?

html - 保持图像纵横比的图像表

Ruby:如何将数组的元素与前缀连接在一起?

cucumber - 为众多客户提供 Watir-Webdriver 现场覆盖的方法

javascript - 为什么在 tablesorter 列上排序删除水平滚动条

html - 创建导航栏,其中悬停时每个链接都有不同的颜色