手机自动化测试: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. Unity渲染优化中文翻译(一)——定位渲染问题

    最近有一点个人的时间,尝试一下自己翻译一下英文的 Optimizing graphics rendering in Unity Games, 这儿附上英文链接: 个人英文水平有限,unity图像学知识 ...

  2. Top 10 Books For Advanced Level Java Developers

    Java is one of the most popular programming language nowadays. There are plenty of books for beginne ...

  3. devexpress设置皮肤、字体以及折叠菜单、伸缩Panel的实现

    1.为了体现系统的个性化,越来越多的系统增加了换肤功能.这里例举一个devexpress实现换肤的案例,效果图对比: 第二张图片中更换了皮肤与字体. 2.皮肤数据源绑定代码: //循环添加皮肤名称 f ...

  4. BZOJ 3924: [Zjoi2015]幻想乡战略游戏(动态点分治)

    这种动态点分治嘛,GDKOI时听打到了,也有同学讲到了,所以印象比较深刻也就想出来了,然后就在实现方面卡了好久= = 不得不说CLJ说得真的太简单了,实现方面根本没提. 首先我们可以先用树分治构建出这 ...

  5. BZOJ 3391: [Usaco2004 Dec]Tree Cutting网络破坏(搜索)

    这道直接遍历一遍求出每个点的子节点数目就行了= = CODE: #include<cstdio>#include<iostream>#include<algorithm& ...

  6. linux oracle 10g tar.gz :xhost: unable to open display

    关于这个问题,最总要的一点是要理解xhost的作用,是干什么的,在下面的介绍中可以基本了解到,只要这个问题解决了,oracle就可以顺利安装了(这是建立在我还没碰到其它问题的基础上). 1. 以roo ...

  7. 关于ReentrantLock和Condition的用法

    这篇博客是过年后的第一篇博客,2.13正式上班,之前在家休年假.上班第一天公司说有个紧急的项目需要上线,所以我们连续加了两个星期的班,直到上个周六还在加班,终于成功上线了.今天是2月的最后的一天,继续 ...

  8. [Selenium With C#学习笔记] Lesson-03 超级链接

    超级链接或链接是Web页面的基本元素之一,而通过超级链接使得万维网可以互联互通.一个典型的链接如下所示: HTML源码如下所示: <a href="index.html" i ...

  9. Python 3 读写文件的简单方法!

    Python 3 读写文件的简单方法! a = open('test.txt','w') 这行代码创建了一个名为test的文本文档,模式是写入(模式分为三种,w代表写入,r代表阅读,a代表在尾行添加) ...

  10. 基于 socket.io, 简单实现多平台类似你猜我画 socket 数据传输

    一.前言 socket.io 实现了实时双向的基于事件的通讯机制,是基于 webSocket 的封装,但它不仅仅包括 webSocket,还对轮询(Polling)机制以及其它的实时通信方式封装成了通 ...