1

モーダルウィンドウにアクセスするために、watirwikiの例を試しました。しかし、引数エラーが発生していました。watir3バージョンで試しています。

    puts b.modal_dialog(:title, "showModalDialog Method Sample Target Page").exists?
    puts b.modal_dialog(:title, "showModalDialog Method Sample Target Page").title
    b.modal_dialog(:title, "showModalDialog Method Sample Target Page").close
    b = Watir::Browser.new()
    b.goto("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog.htm")
    b.button(:value,"Push To Create").click_no_wait

エラーメッセージ

    C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/contai
    ner.rb:60:in `modal_dialog': wrong number of arguments (2 for 0) (ArgumentError) from C:/webtest/popup.rb:29:in `<main>'

誰かがwatir3を使用してモーダルウィンドウにアクセスする方法を手伝ってもらえますか

ありがとう

4

1 に答える 1

2

受け取ったエラーは、メソッドで実際に取得されるよりも多くの引数を指定していることを示しています。

Watir内で実際のモーダルメソッドを使用するための呼び出しは一度もありませんでしたが、提供したページですばやく実験した後、次を使用してモーダルを操作することができました。

b.goto("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog.htm")
b.button(:id => "dCommand").click_no_wait
puts b.modal_dialog.text

上記の例では、モーダルのテキストを出力しましたが、おそらく通常のWatirコマンドで置き換えることができます。

どのモーダルと対話するかを示す引数の要件は、Watir 3.0以前では削除されたように見えます(おそらく、1つしか対話できないためですか?)。私は主にFirefoxでテストしているので、Watir-webdriverに移行しました。これがいつ変更されたかはわかりませんが、3.0では引数を受け入れないようです。

于 2012-05-07T02:13:43.783 に答える