5

ユーザー拡張機能セレンの拡張について読みましたが、作成しているカスタムコマンド内からコマンドを呼び出す方法を知りたいと思っています。

Selenium IDEオプションのSeleniumコア拡張機能(user-extensions.js)に次のようなファイルを追加しました。

// selenium-action-example.js

Selenium.prototype.doExample = function() {
  this.doOpen("/"); // doesn't waitForPageToLoad like the command does

  // These two commands are equivalent to the clickAndWait command. NOT!
  // For proof, see the filterForRemoteControl function:
  // http://code.google.com/p/selenium/source/browse/trunk/ide/src/extension/content/formats/formatCommandOnlyAdapter.js?r=8284#68
  this.doClick("css=a#example");
  this.doWaitForPageToLoad(); // doesn't wait at all

  this.doClick("link=Example");
  this.doWaitForElementPresent("example"); // error! undefined function
  this.doClick("example");
};

つまり、カスタムアクション内でクリックの合間に物事を待つにはどうすればよいですか?

4

2 に答える 2

2

あなたの命令

this.doWaitForPageToLoad(); // doesn't wait at all

括弧内に待機時間を指定していないため、待機しません。あなたはそれを次のように書くべきです

this.doWaitForPageToLoad(30000); // time in milliseconds

別のコマンドをツアーする

this.doWaitForElementPresent("example"); // error! undefined function

Seleniumには機能がないためです。要素を待つときはいつでも、要素が存在するかどうかをチェックするので、要素が表示/存在するまで待つ必要があります。For ループと ispresent コマンドを使用すると、それを行うことができます。

よろしく

于 2011-06-29T05:43:42.533 に答える
0

現在のバージョンの Selenium では、ページの読み込みを待機することはできません。私が見る限り、これは doWaitForPageToLoad が現在の Selenium IDE コマンドの終了まで待機を延期するためです。つまり、ページの読み込みを待つと、ページが読み込まれるまでテストの実行が停止しますが、実際の JavaScript 関数の実行は停止しません。これが実行されたこと。

この時点で、関数を 2 つに分割する必要があります。

于 2012-01-03T10:20:35.337 に答える