5

我阅读了有关用户扩展扩展 selenium的信息,但想知道如何从我正在创建的自定义命令中调用命令。

我在 Selenium IDE Options 中的 Selenium core extensions (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 函数这是执行的。

此时,您将不得不将您的功能一分为二。

于 2012-01-03T10:20:35.337 回答