1

右クリックすると、コンテキスト メニューが表示され、いくつかの Selenium コマンドが提供されます。すべての Selenium コマンドを提供するわけではありません。コマンドのリストは動的で、主に使用される selenium コマンドで更新されます。コンテキスト メニューのコマンド リストを静的にしたい。どうすればそれを行うことができますか?

4

1 に答える 1

2

It's easy to extend the Selenium IDE to add your own custom commands to the right-click context menu.

Specifically, you need to write some Javascript to add the extra commands you need to CommandBuilders.

Adding Command Builders. Command Builders help users adding commands to the test by showing available commands in the context menu when you right-click the element.

Selenium 拡張機能のページには多くの例があります。たとえば、これは HTML 選択要素に関連するコマンドをメニューに表示する方法の優れたデモンストレーションです。

CommandBuilders.add('accessor', function(window) {
// Define the command that we will return
var result = { accessor: "selectedLabel", disabled: true };

// Determine if the user has clicked on a select tag
var element = this.getRecorder(window).clickedElement;
if (element && element.tagName && 'select' == element.tagName.toLowerCase()) {

    // The target is the select element
    result.target = this.getRecorder(window).clickedElementLocators;
    result.disabled = false;

    var selectedIndex = element.selectedIndex;
    if (selectedIndex == -1) {
        // Handle no selection as the empty string
        result.value = '';
    }
    else {
        // Capture the inner HTML (the text shown in the select) as the value to be matched
        var selectedOption = element.options[selectedIndex];
        result.value = exactMatchPattern(selectedOption.innerHTML);
    }
}
return result;
    });

拡張機能を作成したら、Selenium IDE の [オプション] -> [オプション] で簡単に手動でロードしたり、Firefox プラグインの一部としてバンドルしたりできます (良いチュートリアルがここにあります) 。

于 2010-11-12T21:48:33.987 に答える