手机自动化测试:Appium源码分析之跟踪代码分析七
手机自动化测试:Appium源码分析之跟踪代码分析七
该模块中定义了36种不同的状态,以及状态的解释信息,还有一个模块方法,这个模块相对简单
36种状态
1个json字符串定义了36个元素,每一元素代表了一个状态,每一个状态有一个名称,然后对应一个json字符串,该json字符串中有code值和summary值:code为×××,summary值为string字符串。
var codes = {
Success: {
code: 0,
summary: 'The command executed successfully.'
},
NoSuchDriver: {
code: 6,
summary: 'A session is either terminated or not started'
},
NoSuchElement: {
code: 7,
summary: 'An element could not be located on the page using the given search parameters.'
},
NoSuchFrame: {
code: 8,
summary: 'A request to switch to a frame could not be satisfied because the frame could not be found.'
},
UnknownCommand: {
code: 9,
summary: 'The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.'
},
StaleElementReference: {
code: 10,
summary: 'An element command failed because the referenced element is no longer attached to the DOM.'
},
ElementNotVisible: {
code: 11,
summary: 'An element command could not be completed because the element is not visible on the page.'
},
InvalidElementState: {
code: 12,
summary: 'An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).'
},
UnknownError: {
code: 13,
summary: 'An unknown server-side error occurred while processing the command.'
},
ElementIsNotSelectable: {
code: 15,
summary: 'An attempt was made to select an element that cannot be selected.'
},
JavaScriptError: {
code: 17,
summary: 'An error occurred while executing user supplied JavaScript.'
},
XPathLookupError: {
code: 19,
summary: 'An error occurred while searching for an element by XPath.'
},
Timeout: {
code: 21,
summary: 'An operation did not complete before its timeout expired.'
},
NoSuchWindow: {
code: 23,
summary: 'A request to switch to a different window could not be satisfied because the window could not be found.'
},
InvalidCookieDomain: {
code: 24,
summary: 'An illegal attempt was made to set a cookie under a different domain than the current page.'
},
UnableToSetCookie: {
code: 25,
summary: 'A request to set a cookie\'s value could not be satisfied.'
},
UnexpectedAlertOpen: {
code: 26,
summary: 'A modal dialog was open, blocking this operation'
},
NoAlertOpenError: {
code: 27,
summary: 'An attempt was made to operate on a modal dialog when one was not open.'
},
ScriptTimeout: {
code: 28,
summary: 'A script did not complete before its timeout expired.'
},
InvalidElementCoordinates: {
code: 29,
summary: 'The coordinates provided to an interactions operation are invalid.'
},
IMENotAvailable: {
code: 30,
summary: 'IME was not available.'
},
IMEEngineActivationFailed: {
code: 31,
summary: 'An IME engine could not be started.'
},
InvalidSelector: {
code: 32,
summary: 'Argument was an invalid selector (e.g. XPath/CSS).'
},
SessionNotCreatedException: {
code: 33,
summary: 'A new session could not be created.'
},
MoveTargetOutOfBounds: {
code: 34,
summary: 'Target provided for a move action is out of bounds.'
},
NoSuchContext: {
code: 35,
summary: 'No such context found.'
}
};
一个模块方法
if (typeof module !== "undefined") {
//首先将codes所指的json字符串赋值给模块对象codes(可以供外部调用)
module.exports.codes = codes;
//然后定义供外部调用的函数getSummaryByCode
module.exports.getSummaryByCode = function (code) {
//以10进制来解析code
code = parseInt(code, 10);
for (var c in codes) {
if (typeof codes[c].code !== "undefined" && codes[c].code === code) {
//根据code值找到对应的summary描述信息
return codes[c].summary;
}
}
return 'An error occurred';
};
}
当其他模块加载status模块的时候,该模块自身会检查是否已经初始化过了,如果没有初始化,那就需要执行if方法体的代码。if方法就是将保存36种状态的json字符串串提供给外界,且提供了一个根据code值找到summary值的函数getSummaryByCode。
转载于:https://blog.51cto.com/10988776/1728182
手机自动化测试:Appium源码分析之跟踪代码分析七相关推荐
- 手机自动化测试:Appium源码分析之跟踪代码分析四 1
手机自动化测试:Appium源码分析之跟踪代码分析四 控制器模块 // Appium webserver controller methods // https://github.com/hugs/a ...
- mybatis源码之执行insert代码分析
系列文档: mybatis源码之创建SqlSessionFactory代码分析 mybatis源码之创建SqlSessionFactory代码分析 - mapper xml解析 mybatis源码之执 ...
- 手机自动化测试:Appium源码分析之跟踪代码分析四 5
doClick exports.doClick = function (req, res) { var elementId = req.params.elementId || req.body.ele ...
- 手机自动化测试:appium源码分析之bootstrap八
手机自动化测试:appium源码分析之bootstrap八 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大 ...
- 手机自动化测试:appium源码分析之bootstrap十二
手机自动化测试:appium源码分析之bootstrap十二 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请 ...
- 手机自动化测试:appium源码分析之bootstrap七
手机自动化测试:appium源码分析之bootstrap七 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.poptest测试开发 ...
- CTS(11)---android自动化测试CTS源码分析之一
android自动化测试CTS源码分析之一 1, 概述 CTS(Compatibility Test Suite)全名兼容性测试,主要目的就是让Android设备开发商能够开发出兼容性更好的andro ...
- app自动化测试之Appium 源码分析
Appium 是由 Node.js 来实现的 HTTP 服务,它并不是一套全新的框架,而是将现有的优秀的框架进行了集成,在 Selenium WebDriver 协议(JsonWireProtocol ...
- JAVA计算机毕业设计手机电子商城源码+系统+mysql数据库+lw文档
JAVA计算机毕业设计手机电子商城源码+系统+mysql数据库+lw文档 JAVA计算机毕业设计手机电子商城源码+系统+mysql数据库+lw文档 本源码技术栈: 项目架构:B/S架构 开发语言:Ja ...
- 直播开篇——电商直播系统源码直播场景和技术分析
一.直播场景和技术分析 好吧,既然你们非要搞什么直播,我就开始写写直播吧,怪不得WebRTC是下一代关键技术,直播的一些业务页必须要用WebRTC来实现 1. 电商直播系统源码场景分析 秀场直播 这个 ...
最新文章
- SAP MM 采购订单与相关合同的价格差异问题分析
- 微软亚洲研究院开源图数据库GraphView
- console 非常实用的方法
- SAP订单编排和流程增强概述
- linux中脚本循环语句,Shell脚本循环语句
- CSAPP Bomb Lab记录
- 元素显示模式转换(HTML、CSS)
- 【备忘】船舶的几个吨位概念
- linux程序内码,windows系统与linux系统的内码转换总结
- ubuntu 修改IP,网关等
- 人工智能导论(专家系统)
- NPS之Socks流量分析以及未授权复现
- DC工具的基本使用(一)
- 从雀书无代码应用——浅谈零代码开发平台(上)
- 阿里云-视频点播服务API调用
- 兽医外科设备的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
- iMazing苹果电脑版怎么下载?mac苹果手机备份软件
- 痞子衡嵌入式:盘点国内Cortex-M内核MCU厂商高主频产品(2023)
- Simulink —— Scope图像的编辑
- zone web.cluster.zone/IN: NS ‘dns.web.cluster.web.cluster.zone‘ has no address records (A or AAAA)
热门文章
- 从零基础入门Tensorflow2.0 ----一、3.1 实战深度神经网络
- CSS学习总结(4)——盒模型/背景属性
- 一种基于DCNN模型的云检测方法介绍
- modis数据产品行列号以及数据行列号
- OkHttp之BridgeInterceptor简单分析
- java 雪崩效应,Jmeter模拟雪崩效应
- laravel mysql rand_Laravel-雄辩或流利的随机行
- linux编译后 空间不足,Linux系统/run/systemd空间不足问题解决
- cacti升级后还是用的旧路径_Flutter1.9升级体验及填坑全攻略
- Flink 新一代流计算和容错——阶段总结和展望