【发布时间】:2014-09-22 02:19:13
【问题描述】:
我已经设法将自定义命令添加到 Selenium IDE,但在支持这些格式时遇到了困难,即 Python WebDriver 格式的扩展版本。在导出为我的自定义格式时生成的脚本中,我添加了以下命令:
# ERROR: Caught exception [unknown command [finalPrice]]
我已将此命令添加到user-extensions.js,如下所示:
Selenium.prototype.doFinalPrice = function (locator) { return ''; }
CommandBuilders.add('action', function (window) {
var result = {
command: 'finalPrice',
target: this.getRecorder(window).clickedElementLocators,
execute: function () { return; },
getDefinition: function () { return true; }
};
return result;
})
并使用以下内容扩展了标准 Python WebDriver format.js:
WDAPI.Driver.prototype.finalPrice = function (locatorType, locator) {
return ["#PRICE", locatorType, locator].join('|');
};
SeleniumWebDriverAdaptor.prototype.finalPrice = function () {
var locator = this._elementLocator(this.rawArgs[0]);
var driver = new WDAPI.Driver();
return driver.finalPrice(locator.type, locator.string);
}
有没有人成功地做到了这一点,如果有,你能指出我哪里出错了吗?正如我所说,Selenium IDE 中的命令本身工作正常,只是导出到我的自定义格式失败。任何帮助将不胜感激。
【问题讨论】:
标签: javascript python selenium selenium-ide