鉴于这个非常简单的 Selenium 测试:
使用 selenium-side-runner 运行 .side 项目时如何提供用户名和密码变量?作为命令行参数,在 .side.yml 配置文件中静态键入或来自外部数据文件。除了在 .side 文件中硬编码用户凭据之外的任何选项。
作为参考,这里是 .side 文件的内容:
{
"id": "2fcada56-fdb1-4acd-9d95-451e3d74c8f3",
"version": "2.0",
"name": "Todo",
"url": "https://www.todo-cloud.com/",
"tests": [{
"id": "8e83c690-453d-4602-b187-015e9ee4cfe7",
"name": "Login",
"commands": [{
"id": "453101ad-3249-47e9-bc87-860bbfdea343",
"comment": "",
"command": "open",
"target": "https://www.todo-cloud.com/#/welcome/login",
"targets": [],
"value": ""
}, {
"id": "f14304b6-4f66-4b79-b1a5-39bd206f29af",
"comment": "",
"command": "type",
"target": "name=username",
"targets": [
["name=username", "name"],
["css=.ng-valid", "css:finder"],
["xpath=//input[@name='username']", "xpath:attributes"],
["xpath=//input", "xpath:position"]
],
"value": "${username}"
}, {
"id": "a2520d2d-100b-4be4-93f7-d88f3ede804a",
"comment": "",
"command": "type",
"target": "name=password",
"targets": [
["name=password", "name"],
["css=.password", "css:finder"],
["xpath=//input[@name='password']", "xpath:attributes"],
["xpath=//div[2]/div/input", "xpath:position"]
],
"value": "${password}"
}]
}],
"suites": [{
"id": "31c08a71-044c-4917-87e8-fcaacf3cd7ac",
"name": "Default Suite",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["8e83c690-453d-4602-b187-015e9ee4cfe7"]
}],
"urls": ["https://www.todo-cloud.com/"],
"plugins": []
}