如何在我的 Selenium 命令行 (selenium-side-runner) 测试中插入暂停(延迟)?
How do I insert a pause (delay) in my Selenium command line (selenium-side-runner) test?
我正在使用 selenium-side-runner v 3.11.0 并尝试在我的测试中插入一个暂停(延迟),以便在单击之后,在下一个操作之前有一段时间。这个我试过了
, {
"id": "ec6aa5e8-c72b-4bf5-8061-a7a360370923",
"comment": "",
"command": "click",
"target": "linkText=Log in",
"targets": [
["linkText=Log in", "linkText"],
["css=.login-link", "css:finder"],
["xpath=//a[contains(text(),'Log in')]", "xpath:link"],
["xpath=//div[@id='header-bottom-right']/span/a", "xpath:idRelative"],
["xpath=//a[contains(@href, 'https://www.reddit.com/login')]", "xpath:href"],
["xpath=//div[3]/span/a", "xpath:position"],
["xpath=//a[contains(.,'Log in')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "fbf35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "pause",
"target": "",
"targets": [],
"value": "35000"
},
但我注意到暂停根本没有激活。尽管在上面我已经等待了很长时间(35 秒),但测试会直接跳到下一个命令。我在 Mac Mojave 上使用 chromedriver。插入暂停命令的正确方法是什么?我运行在命令行上的测试是这样的
PATH=/Users/davea/Documents/workspace/starter_project/selenium/dev/:$PATH selenium-side-runner --headless -c "browserName=chrome" /tmp/81a312ad-8fe1-4fb0-b93a-0dc186c3c585.side
我认为延迟值应该放在 target
{
"id": "fbf35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "pause",
"target": "35000",
"targets": [],
"value": ""
}
暂停目标以毫秒为单位,因此将您的秒数转换为毫秒并将其添加到 目标 字段
{
"id": "ec6aa5e8-c72b-4bf5-8061-a7a360370923",
"comment": "",
"command": "click",
"target": "linkText=Log in",
"targets": [
["linkText=Log in", "linkText"],
["css=.login-link", "css:finder"],
["xpath=//a[contains(text(),'Log in')]", "xpath:link"],
["xpath=//div[@id='header-bottom-right']/span/a", "xpath:idRelative"],
["xpath=//a[contains(@href, 'https://www.reddit.com/login')]", "xpath:href"],
["xpath=//div[3]/span/a", "xpath:position"],
["xpath=//a[contains(.,'Log in')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "fbf35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "pause",
"target": 35000, #for 35 seconds
"targets": [],
"value": ""
},
我正在使用 selenium-side-runner v 3.11.0 并尝试在我的测试中插入一个暂停(延迟),以便在单击之后,在下一个操作之前有一段时间。这个我试过了
, {
"id": "ec6aa5e8-c72b-4bf5-8061-a7a360370923",
"comment": "",
"command": "click",
"target": "linkText=Log in",
"targets": [
["linkText=Log in", "linkText"],
["css=.login-link", "css:finder"],
["xpath=//a[contains(text(),'Log in')]", "xpath:link"],
["xpath=//div[@id='header-bottom-right']/span/a", "xpath:idRelative"],
["xpath=//a[contains(@href, 'https://www.reddit.com/login')]", "xpath:href"],
["xpath=//div[3]/span/a", "xpath:position"],
["xpath=//a[contains(.,'Log in')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "fbf35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "pause",
"target": "",
"targets": [],
"value": "35000"
},
但我注意到暂停根本没有激活。尽管在上面我已经等待了很长时间(35 秒),但测试会直接跳到下一个命令。我在 Mac Mojave 上使用 chromedriver。插入暂停命令的正确方法是什么?我运行在命令行上的测试是这样的
PATH=/Users/davea/Documents/workspace/starter_project/selenium/dev/:$PATH selenium-side-runner --headless -c "browserName=chrome" /tmp/81a312ad-8fe1-4fb0-b93a-0dc186c3c585.side
我认为延迟值应该放在 target
{
"id": "fbf35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "pause",
"target": "35000",
"targets": [],
"value": ""
}
暂停目标以毫秒为单位,因此将您的秒数转换为毫秒并将其添加到 目标 字段
{
"id": "ec6aa5e8-c72b-4bf5-8061-a7a360370923",
"comment": "",
"command": "click",
"target": "linkText=Log in",
"targets": [
["linkText=Log in", "linkText"],
["css=.login-link", "css:finder"],
["xpath=//a[contains(text(),'Log in')]", "xpath:link"],
["xpath=//div[@id='header-bottom-right']/span/a", "xpath:idRelative"],
["xpath=//a[contains(@href, 'https://www.reddit.com/login')]", "xpath:href"],
["xpath=//div[3]/span/a", "xpath:position"],
["xpath=//a[contains(.,'Log in')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "fbf35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "pause",
"target": 35000, #for 35 seconds
"targets": [],
"value": ""
},