微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我正在Ubuntu上为Web编写watir-webdriverRuby 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”.这表示该项目已被识别,但仍未发生任何事情.

解决方法

你尝试过使用javascript命令吗?

例如:

browser.iframe.button(:id,"id_button").fire_event("onclick")

如果这不起作用,请尝试使用IRB进行调试.

PS:我会写如下:

browser.iframe(:id,/iframe/).button(:id,/button/).fire_event("onclick")

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐