手机自动化测试:Appium源码分析之跟踪代码分析七

 

poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。poptest推出手机自动化测试的课程,讲解appuim的实际应用,培训全程用商业项目, 大家可以加qq群进行交流:195983133。

该模块中定义了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。

手机自动化测试:Appium源码分析之跟踪代码分析七的更多相关文章

  1. 手机自动化测试:Appium源码分析之跟踪代码分析九

    手机自动化测试:Appium源码分析之跟踪代码分析九   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家 ...

  2. 手机自动化测试:Appium源码分析之跟踪代码分析八

    手机自动化测试:Appium源码分析之跟踪代码分析八   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家 ...

  3. 手机自动化测试:Appium源码分析之跟踪代码分析六

    手机自动化测试:Appium源码分析之跟踪代码分析六   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.poptest推出手机自 ...

  4. 手机自动化测试:Appium源码分析之跟踪代码分析五

    手机自动化测试:Appium源码分析之跟踪代码分析五   手机自动化测试是未来很重要的测试技术,作为一名测试人员应该熟练掌握,POPTEST举行手机自动化测试的课程,希望可以训练出优秀的手机测试开发工 ...

  5. 手机自动化测试:appium源码分析之bootstrap三

    手机自动化测试:appium源码分析之bootstrap三   研究bootstrap源码,我们可以通过代码的结构,可以看出来appium的扩展思路和实现方式,从中可以添加我们自己要的功能,针对app ...

  6. 手机自动化测试:appium源码分析之bootstrap二

    手机自动化测试:appium源码分析之bootstrap二   在bootstrap项目中的io.appium.android.bootstrap.handler包中的类都是对应的指令类, priva ...

  7. 手机自动化测试:appium源码分析之bootstrap一

    手机自动化测试:appium源码分析之bootstrap一   前言: poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.popte ...

  8. 手机自动化测试:appium源码分析之bootstrap十七

    手机自动化测试:appium源码分析之bootstrap十七   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...

  9. 手机自动化测试:appium源码分析之bootstrap十六

    手机自动化测试:appium源码分析之bootstrap十六   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...

随机推荐

  1. 表单界面的兼容PC手机端解决方案

    就当写一篇随笔吧~上星期还在做加盟模块(兼容微信端),这星期已经加班做快递扫码模块(react+node),所以我感觉只有弹药备足了才能稍微轻松些应对各种需求.实话说在同个部门的大佬面前差距确实大,如 ...

  2. mysql远程连接权限

    环境:mysql6.0 .Navicat Premium 用户名:root 密码:123456  本地连接无问题 远程连接mysql的时候应该碰到Navicat Premium 报错. 错误代码是11 ...

  3. JavaScript中数组Array方法详解

    ECMAScript 3在Array.prototype中定义了一些很有用的操作数组的函数,这意味着这些函数作为任何数组的方法都是可用的. 1.Array.join()方法 Array.join()方 ...

  4. 【转】Docker —— 从入门到实践

    http://yeasy.gitbooks.io/docker_practice/content/index.html Docker 是一个开源项目,诞生于 2013 年初,最初是 dotCloud ...

  5. JS中的作用域链

    在js中数据的声明方式有两种: 1.用var声明,例如:var num = 10: 2.直接声明,例如:num = 10: 两种声明方式在某些情况下是有区别的: var data = 10; func ...

  6. 【2017-03-05】函数基础、函数四种结构、ref和out参数、递归

    一.函数基础 1.函数/方法:非常抽象独立完成某项功能的一个个体 2.函数的作用: 提高代码的重用性提高功能开发的效率提高程序代码的可维护性 3.分类 固定功能函数高度抽象函数 4.函数四要素:输入, ...

  7. Java基础之路(一)下--引用数据类型之数组

    上次我们说了java的基础数据类型,今天我们就来说一下引用数据类型中的数组. 什么是数组 数组:存储在一个连续的内存块中的相同数据类型(引用数据类型)的元素集合. 数组中的每一个数据称之为数组元素,数 ...

  8. 前端资讯周报 2.27 - 3.5: 如何设计一个优秀的HTML接口,深入理解line-height

    从本周起,每周一我都会分享上一周我订阅的技术站点中,和解决问题的过程中阅读到的值得分享的文章,或者视频教程,又或者图书. 个人认为国外的技术文章质量较高,而且发布的技术资讯也走在行业前沿,所以比较关注 ...

  9. 10条建议让你创建更好的jQuery插件

    在开发过很多 jQuery 插件以后,我慢慢的摸索出了一套开发jQuery插件比较标准的结构和模式.这样我就可以 copy & paste 大部分的代码结构,只要专注最主要的逻辑代码就行了.使 ...

  10. 1632: [Usaco2007 Feb]Lilypad Pond

    1632: [Usaco2007 Feb]Lilypad Pond Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 404  Solved: 118[Sub ...