1.如果没有安装firefox 下载fireFox
2.Selenium IDE
1. 下载 Selenium IDE https://addons.mozilla.org/firefox/2079/
2. Firefox > Tools > Selenium IDE
3. Selenium IDE > Options > Options...
1. 选择 Format 选项.
2. 点击添加按钮.
3. (Name of the fommat )给新添的起个名字 testSelenium
4. 粘贴下面JS代码到文本恇
5. 点击确定
4. 点击工具 菜单 Selenium IDE > Options > Format > testSelenium
5. 可以录脚本了
testSelenium.js
var SEPARATORS = {
pipe: "|",
comma: ",",
tab: "\t"
};
function formatCommands(commands) {
var result = '';
var sep = SEPARATORS[options.separator];
var prefix = options.wrap == 'true' ? sep : "";
var postfix = prefix;
for (var i = 0; i < commands.length; i++) {
var command = commands[i];
if (command.type == 'command') {
result += prefix + command.command + sep + command.target + sep + command.value + postfix + "\n";
}
}
return result;
}
function parse(testCase, source) {
var doc = source;
var commands = [];
var sep = SEPARATORS[options.separator];
var base = options.wrap == 'true' ? 1 : 0;
while (doc.length > 0) {
var line = /(.*)(\r\n|[\r\n])?/.exec(doc);
var array = line[1].split(sep);
if (array.length >= (base+3)) {
var command = new Command();
command.command = array[base+0];
command.target = array[base+1];
command.value = array[base+2];
commands.push(command);
}
doc = doc.substr(line[0].length);
}
testCase.setCommands(commands);
}
function format(testCase, name) {
return formatCommands(testCase.commands);
}
options = {
separator: 'pipe',
wrap: 'true'
};
configForm =
'<descrīption>Separator</descrīption>' +
'<menulist id="options_separator">' +
'<menupopup>' +
'<menuitem label="Pipe" value="pipe"/>' +
'<menuitem label="Comma" value="comma"/>' +
'<menuitem label="Tab" value="tab"/>' +
'</menupopup>' +
'</menulist>' +
'<checkbox id="options_wrap" label="Wrap command with separator"/>';
昨天我在网上查的资料,我按照上面的步骤操作了一下,可以录制成功了.如果也有朋友想学习的话,可以参考一下.
我也希望可以和大家多多交流一下,我还有很多地方搞不清楚@_@