4

私はWeb用のUbuntuでWatir-WebDriverとRuby1.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は例外を出力しませんが、ボタンを押さないでください。

この問題は、InternetExplorerでのみ発生します。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"ました。これは、アイテムが認識されていることを示していますが、それでも何も起こりません。

4

2 に答える 2

1

このコードを試してください

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

さらに詳しい情報が必要な場合は、このリンクを確認してください

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

于 2012-12-19T10:33:45.377 に答える
0

javascriptコマンドを使用してみましたか?

例えば:

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

それでも問題が解決しない場合は、IRBを使用してデバッグしてみてください。

PS:私はそれを次のように書きます:

browser.iframe(:id, /iframe/).button(:id, /button/).fire_event("onclick")
于 2012-09-18T13:16:27.823 に答える