笔记
1.html中的脚本必须位于之间 2.脚本可放置在body和head部分中 3.外部的js文件使用,需要在
window.alert()弹出警告框 document.write写入html文档中 innerHTML写入到HTML元素 console.log()写入到控制台
脚本常用
1.控件的常规操作模板 step = new Step(“操作步骤”); with(step) { isReady = async function() { let spath = ‘’;//通过index或者通配符+具体控件:1./0/0/0/0 2.//{“class”: “UIControl” , “subIndex”: 0} currentStep.foundView = await OCCore.viewWithSPath(spath);//路径查找view return currentStep.foundView; //currentStep.foundView可以属性赋值 }; action = async function() { OCCore.swipTo(up/down/left/right); //控件滑动操作 OCCore.touchAtView(currentStep.foundView); OCCore.waitView(‘spath’, 1);//等待view出现:两个参数,第一个传入路径,第二个传入等待时间 OCCore.waitViewDisappear(‘spath’, 1);//等待view消失 OCCore.viewWithText(‘22’, currentStep.foundView); //等待条件匹配 } } 2.脚本执行过程中常用操作 // 1、如果步骤安装后只有第一次需要:添加这个条件判断 if(appInfo.isFirstTime == 1){ step = new Step(‘点击”隐私政策”’); with(step) { isReady = async function() { // let spath = ‘/0/0/0/0/0/1/0/2/1/0’; let spath = ‘//{“class”: “UIButtonLabel”, “text”: “同意”}’; // let spath = ‘同意’; currentStep.foundView = await OCCore.viewWithSPath(spath); return currentStep.foundView; }; action = async function() { await OCCore.touchAtView(currentStep.foundView); // OCCore.touchXY(253, 577); }; } task.addStep(step); } // 2、延迟1000ms—-注意毫秒哦 await OCCore.sleep(1000); // 3、获取deviceInfo(详细查看sdk中) let width = await deviceInfo.screenSize.width; let height = await deviceInfo.screenSize.height; // 4.调用前面定义的对象 step=Object.assign(new Step(‘’),stepBackToMain); task.addStep(step);