3

Selenium RC(C#)を使用してフォームページを自動化しています。[送信]ボタンをクリックすると、アラートが表示されますRecords Edited Successfully!。このアラートボックスのタイトルは' 'です。The page at http://www.******.com says:

ただし、Seleniumにはこのアラートは表示されません。そして、私はそれを回避することはできません。

これが私が試したことです:

selenium.Click("ctl00_Content_ctl00_btnSubmit");
selenium.WaitForPageToLoad("30000");

結果:次のエラーが発生します: " Selenium.SeleniumException : Timed out after 30000ms"

それから私は試しました:

selenium.Click("ctl00_Content_ctl00_btnSubmit");
selenium.OpenWindow("", "The page at The page at http://www.******.com says:");
selenium.Close();
selenium.WaitForPageToLoad("30000");

結果:3つのウィンドウが開きます(サイト、アラート、および追加のウィンドウ)。何も閉じられません。次のエラーが発生します: " Selenium.SeleniumException : Timed out after 30000ms"

それから私は試しました:

selenium.Click("ctl00_Content_ctl00_btnSubmit");
selenium.SelectWindow("The page at The page at http://www.******.com says:");
selenium.Close();
selenium.WaitForPageToLoad("30000");

結果:次のエラーが発生します: " "Could not find window with title 'The page at http://www.******.com says:'

助言がありますか?この障害を克服するのを手伝ってください。

4

2 に答える 2

4

どうやらこれを行う最も簡単な方法は、スクリプトを使用して alert() 関数をダイアログをポップアップしないものに再定義することです。

((JavascriptExecutor) fDriver).executeScript(
  "window.alert = function(msg) { return true; }"
); 
于 2010-11-18T01:08:52.813 に答える
1

最後に、回避策を見つけました。

    selenium.Click("ctl00_Content_ctl00_btnSubmit");                        
    Thread.Sleep(5000);
    selenium.KeyDownNative("32");
    selenium.KeyUpNative("32");

皆様のご多幸をお祈り申し上げます。

于 2010-11-18T20:52:24.690 に答える