click / dblclick
click/dblclick “selector“;
单击或双击一个HTML的页面元素。
process main () {
// Deepin Technology Community
jumpto "https://www.deepin.org/en/";
wait 2333;
// dblclick
dblclick '#hs-site-navigation > .hs-toggle-menu';
wait 2323;
// click
click '#hs-site-navigation > .hs-toggle-menu';
}
input…by
input “selector“ by “string”;
输入一段字符串到文档框中去。或者
// eg: id="link" class="case" input 'div#link.case' by "hello world.";
move
move “selector“;
对HTML页面元素触发鼠标移入移出的动作。该动作可触发CSShover。
process main () {
jumpto "https://www.deepin.org/en/";
wait 2333;
click '#hs-site-navigation > .hs-toggle-menu';
// 在以下三个页面元素上移动
move '#menu-main span:contains(Projects)';
move '#menu-main span:contains(Download)';
move '#menu-main span:contains(Documents)';
}
hold
hold “selector“;
鼠标持续点住一个元素。具体的示例在下方的drop中。
drop
drop;
鼠标释放一个元素。
process main () {
jumpto "https://jqueryui.com/draggable/";
wait 2333;
//持续点住页面上的一个元素,用move来完成拖拽和指针移动
hold '#content > iframe:nth-child(5) < #draggable';
move '#content > iframe:nth-child(5) < html';
//释放该元素
drop;
}
scroll
scroll “selector“;
滚动页面,保持选中元素位于屏幕中部。
process main () {
jumpto "http://www.lemonce.com";
wait 2333;
//scroll
scroll 'footer';
}
jumpto
jumpto “URL”;
跳转到一个URL链接。back / forward / refresh
back;
forward;
refresh;
back 后退一页;forward 向前移动一页;refresh 刷新当前网页。
process main () {
// The world's leading software development platform · GitHub
jumpto "https://github.com/";
wait 2333;
// Sign up
click "a:contains(Sign up)";
wait 2000;
//back
back;
wait 2000;
//forward
forward;
wait 2000;
//refresh
refresh;
}
wait
wait [time:number]
等待一定的时间(以毫秒为单位)。//编辑器会等待3000毫秒再执行下一个动作 wait 3000;
assert
assert [expression] in [time:number]
断言一个表达式为真或假(在一定的时间内),具体参照以下示例。关于表达式的更多介绍,点击这里。
//断言id为'test'的输入框个数为1个
assert <# "textarea#test"> == 1;
//断言id为'test'的输入框包含'Lemonce'
assert <@ "testarea#test"> ~~ "Lemonce"
//断言id名为'test'的输入框会在两秒钟内出现
assert <# "textarea#test"> in 2000;
process main () {
// The world's leading software development platform · GitHub
jumpto "https://github.com/";
// wait
wait 2333;
// click "login"
click "#user\\[login\\]";
// assert
assert <@'h1'> ~~ "Built" in 1000;
}@'h1'>#>@>#>
upload
upload [“filePath1”,”filePath2”]
如果一个测试需要上传一个文件到一个 web 应用程序,可以采用upload 命令来上传。以下是例子。
注意:在 Windows 系统中路径采用的是”\”,需要用户改为 “/“ 或进行转义 “\\” 才能在灵萌测中运行。如”C:\Users\1.img”需要在灵萌测中改为”C:/Users/1.img”。
#AUTOWAIT 1000
process main () {
// Angular file upload - flow.js
jumpto "http://flowjs.github.io/ng-flow/";
wait 3333;
// 点击 Basic upload
click "div.ng-scope > .drop > span.btn-default";
upload ["C:/1.lc2"];
wait 4000;
// 点击 Single image upload
click "body > div:nth-child(1) > section:nth-child(2) > div:nth-child(10) > div:nth-child(4) > span:nth-child(1)";
upload ["C:/1.jpg","D:/2.png"];
// 当只支持上传一个文件时,lemonce会默认上传第一个文件
wait 4000;
}