ma1*_*w28 5 extension-methods selenium click selenium-ide selenium-rc
我阅读了有关用户扩展和扩展selenium但我想知道如何从我正在创建的自定义命令中调用命令.
我在Selenium IDE Options中向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");
};
Run Code Online (Sandbox Code Playgroud)
换句话说,我如何在自定义操作中的点击之间等待?
你的命令
this.doWaitForPageToLoad(); // doesn't wait at all
Run Code Online (Sandbox Code Playgroud)
不等待,因为您没有在括号中指定等待时间。你应该把它写成
this.doWaitForPageToLoad(30000); // time in milliseconds
Run Code Online (Sandbox Code Playgroud)
游览另一个命令
this.doWaitForElementPresent("example"); // error! undefined function
Run Code Online (Sandbox Code Playgroud)
因为 Selenium 中没有任何函数。每当它等待一个元素时,它都会检查该元素是否存在,因此您应该等待时间直到它可见/存在。使用 For 循环和 ispresent 命令就可以做到这一点。
问候
| 归档时间: |
|
| 查看次数: |
2957 次 |
| 最近记录: |