支持表单中的自定义Selenium IDE命令

2024-10-01 17:37:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经设法向Selenium IDE添加了自定义命令,但在某种格式(即pythonwebdriver格式的扩展版本)中支持这些命令时遇到了困难。我在导出自定义脚本时添加了以下命令:

# ERROR: Caught exception [unknown command [finalPrice]]

{cdve添加到以下命令中:

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

^{pr2}$

有没有人成功地做到了这一点?如果成功了,你能指出我的错误在哪里吗?如前所述,Selenium IDE中的命令本身工作正常,只是导出到自定义格式失败了。任何帮助都将不胜感激。在


Tags: 命令版本脚本return格式seleniumfunctionerror
1条回答
网友
1楼 · 发布于 2024-10-01 17:37:20

您应该能够使用用户开发并行javascript函数-扩展名.js. 这样,这些命令将同时存在于webdriver和selenium ide中。最干净的方法是在用户中创建一次-扩展名.js然后在webdriver中引用它。在

看看https://groups.google.com/d/msg/selenium-users/6Sfa1-bLKUQ/1fnoL4ZW3WoJ和{a2},了解如何在用户扩展中弥合到自定义javascript的差距。在

What are user-extensions? These are JavaScript functions/libraries that the user can create and use in order to extend Selenium.

Why do we have to use user-extensions? Simple. If you want to add your own actions, assertions and locator-strategies. This means that there is currently no available command for the type of testing that you would like to accomplish. This also implies that there is no method yet in the Selenium API that will do the action/assertion/locator-strategy that you would like to add.

相关问题 更多 >

    热门问题