运行测试以从文本中提取验证码,在 Selenium IDE 中执行它会返回代码,但是在 selenium-side-runner 中执行时,我收到 d,d,d 或 null,请查看下面的屏幕截图
使用的字符串
return (${sms}.match(/\d+/g));
var regex = (/\d+/g); var sms = ${sms}; var code = sms.match(regex);return (code);
var regex = (/\d+/g); var sms = ${sms}; var code = sms.match(regex);return Number(code);
var regex = (/\d+/g); var sms = ${sms}; var code = sms.match(regex);var integer = parseInt(code, 10); return (integer);
不知道我做错了什么,期望 cli 像在 IDE 中一样返回提取的代码
SIDE文件的完整代码
{
"id": "0b994070-c80e-4d08-a47c-80acfa2cfabe",
"version": "2.0",
"name": "sms",
"url": "https://google.com/",
"tests": [{
"id": "fcd3a0c3-318a-413c-93a9-67d2a6d16afd",
"name": "sms",
"commands": [{
"id": "b5660f01-72af-4406-825b-318d87309f4e",
"comment": "",
"command": "store",
"target": "Your verification code is: 149599. Your code will expire in five minutes. Please do not reply.",
"targets": [],
"value": "sms"
}, {
"id": "f2273604-d068-4164-9341-5d0c317995cf",
"comment": "",
"command": "executeScript",
"target": "return (${sms}.match(/\\d+/g));",
"targets": [],
"value": "verificationCode1"
}, {
"id": "ef17e1ef-69e1-400b-94db-6b1e42c5ed44",
"comment": "",
"command": "echo",
"target": "verificationCode1 ${verificationCode1}",
"targets": [],
"value": ""
}, {
"id": "40fc2f41-ed06-4b53-9322-87425a90db18",
"comment": "",
"command": "executeScript",
"target": "var regex = (/\\d+/g); var sms = ${sms}; var code = sms.match(regex);return (code);",
"targets": [],
"value": "verificationCode2"
}, {
"id": "34838fd8-ea17-48df-b271-6cb48c36add3",
"comment": "",
"command": "echo",
"target": "verificationCode2 ${verificationCode2}",
"targets": [],
"value": ""
}, {
"id": "9ffdbf87-cf35-47fe-bd1b-c8d6c172aa20",
"comment": "",
"command": "executeScript",
"target": "var regex = (/\\d+/g); var sms = ${sms}; var code = sms.match(regex);return Number(code);",
"targets": [],
"value": "verificationCode3"
}, {
"id": "fd668254-6c3d-4fed-8ccb-ee8d7d219314",
"comment": "",
"command": "echo",
"target": "verificationCode3 ${verificationCode3}",
"targets": [],
"value": ""
}, {
"id": "df97f204-1836-4096-8832-63f96bb7d489",
"comment": "",
"command": "executeScript",
"target": "var regex = (/\\d+/g); var sms = ${sms}; var code = sms.match(regex);var integer = parseInt(code, 10); return (integer);",
"targets": [],
"value": "verificationCode4"
}, {
"id": "299f2afc-c5a3-4740-b340-62bc60b4fdaa",
"comment": "",
"command": "echo",
"target": "verificationCode4 ${verificationCode4}",
"targets": [],
"value": ""
}]
}],
"suites": [{
"id": "b84e7765-fa32-4bd2-bcb7-4ee89a5b0e10",
"name": "sms",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["fcd3a0c3-318a-413c-93a9-67d2a6d16afd"]
}],
"urls": ["https://stackoverflow.com/", "https://google.com/"],
"plugins": []
}