好的,所以我在用户扩展中使用了汇总规则,由于某种原因,Selenium会一直说我的gotoIF标签不存在。有谁知道为什么或如何解决这个问题?语言是JS(JavaScript)
var manager = new RollupManager();
manager.addRollupRule({
name: 'FRLanguageCheck'
, description: 'Check the language to make sure its in french'
, args: [
], commandMatchers: [
]
, getExpandedCommands: function(args) {
var commands = [];
commands.push({
command: 'storeTextPresent'
, target: 'English'
, value: 'LanguageCheck'
});
commands.push({
command: 'gotoIf'
, target: '${LanguageCheck}==false'
, value: 'StepWithWrongLanguage'
});
commands.push({
command: 'gotoIf'
, target: '${LanguageCheck}==true'
, value: 'StepWithRightLanguage'
});
commands.push({
command: 'label'
, target: 'StepWithWrongLanguage'
, value: ''
});
commands.push({
command: 'click'
, target: 'TestLanguageChangeToFrench failed. The site was not in French.'
, value: ''
});
commands.push({
command: 'label'
, target: 'StepWithRightLanguage'
, value: ''
});
return commands;
}
});
这是我从硒中得到的错误消息
[error] [selblocks] Error @1: [rollup|FRLanguageCheck] Target label 'StepWithRightLanguage' is not found.
[warn] [selblocks] __Stack Trace__
[error] Unexpected Exception: Error: @1: [rollup|FRLanguageCheck] Target label 'StepWithRightLanguage' is not found..
最佳答案
好的,所以我没有将硒与XML以外的其他语言一起使用,因此对任何错误表示歉意。欢迎进行编辑。 (这是Java吗?)
您无需同时指定true和false,但我确实知道您的雇主可能会在某些特定的事情之后提出要求。您将要分隔gotoIf
语句,因为一个将隐藏另一个。
var manager = new RollupManager();
manager.addRollupRule({
name: 'FRLanguageCheck'
, description: 'Check the language to make sure its in french'
, args: [
], commandMatchers: [
]
, getExpandedCommands: function(args) {
var commands = [];
commands.push({
command: 'storeTextPresent'
, target: 'English'
, value: 'LanguageCheck'
});
commands.push({
command: 'gotoIf'
, target: '${LanguageCheck}==false'
, value: 'StepWithWrongLanguage'
});
commands.push({
command: 'label'
, target: 'StepWithWrongLanguage'
, value: ''
});
commands.push({
command: 'storeTextPresent'
, target: 'English'
, value: 'LanguageCheck'
});
commands.push({
command: 'gotoIf'
, target: '${LanguageCheck}==true'
, value: 'StepWithRightLanguage'
});
commands.push({
command: 'click'
, target: 'TestLanguageChangeToFrench failed. The site was not in English.'
, value: ''
});
commands.push({
command: 'label'
, target: 'StepWithRightLanguage'
, value: ''
});
return commands;
}
});
我建议只使用一个
gotoIf
语句,因为当前您只有一个命令。如果确实要使用两个,则可能需要向StepWithWrongLanguage
添加一串命令,以便如果其语言为法语,则它会更改语言,然后第二个gotoIf
语句可以验证它是否确实已更改。关于javascript - 具有gotoIf和label的Selenium IDE汇总规则,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42259523/