【问题标题】:Watir/Selenium2 Nothing happens after clicking on an element inside iframe in Internet Explorer 9Watir/Selenium2 在 Internet Explorer 9 中单击 iframe 内的元素后没有任何反应
【发布时间】:2012-12-19 18:33:45
【问题描述】:

我正在 Ubuntu 上使用 Watir-WebDriver 和 Ruby 1.9.2 为 web 编写自动测试。我有一些包含几个元素的 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"。这表明该项目已被识别,但仍然没有任何反应。

【问题讨论】:

    标签: html ruby watir-webdriver selenium-webdriver


    【解决方案1】:

    请试试这个代码

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

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

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

    【讨论】:

      【解决方案2】:

      您是否尝试过使用 javascript 命令?

      例如:

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

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

      PS:我会这样写:

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

      【讨论】:

        猜你喜欢
        • 2021-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多