我已经安装Selenium extension
了 google Chrome Selenium IDE,所以我可以记录我的测试并将测试文件保存.side
为一个json
文件。它包含
{id , command , target , value}
.
{ "id": "70a08bcc-b351-4ec6-b64d-f833f09adfa2",
"name": "Untitled Project",
"url": "http://example.io",
"tests": [
{
"id": "0b5184ff-4873-459b-b55b-77d56ebf5f6e",
"name": "Untitled",
"commands": [
{
"id": "35b40ae7-1ada-46d9-8c65-d8faaf1af753",
"command": "open",
"target": "/",
"value": ""
},
{
"id": "0e0bd8b3-4301-4ac6-8cd6-4b01fa94f68d",
"command": "type",
"target": "name=login",
"value": "test@tets.io"
},
{
"id": "078da69d-eec3-44b8-b793-53b401a18ac4",
"command": "clickAt",
"target": "//div[@id='cloud-ui']/div/div[3]/div/button/span",
"value": "24,17"
}...
我想知道是否有自动运行测试文件的解决方案JavaScript
,例如读取文件并执行命令的插件?
如果不是,那么创建我自己的 JavaScript 函数来获取 json 对象{id , command , target , value}
并执行命令呢?
举个例子 :
{
"id": "512a84b8-c3b0-4cb6-88b4-025d28502f1f",
"command": "clickAt",
"target": "css=li.active > a",
"value": "18,62"
}
我们可以使用selenium-webdriver
driver.findElement(By.css("li > a > span")).click();