手机自动化测试: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. CLAHE的实现和研究

    CLAHE算法对于医学图像,特别是医学红外图像的增强效果非常明显. CLAHE  https://en.wikipedia.org/wiki/Adaptive_histogram_equalizati ...

  2. NoSql研究报告

    NoSql研究报告 1.概述 随着互联网的不断发展,信息系统的数据变得越来越多,关系型数据库逐渐面临着难以克服的障碍,主要体现在: 对数据库的高并发读写需求 对海量数据的高效率存储和访问需求 对数据库 ...

  3. 在.NET Core控制台应用程序中使用强类型配置

    想象一下,你写一个控制台应用程序,你想要从配置文件中以强类型方式读取配置. .NET Core 可以帮助我们解决. 通常我会在ASP.NET Core MVC中演示,但简单起见,只在控制台应用程序中演 ...

  4. RAC之常用方法-----新手入门

    年后换工作新入职,公司开发在使用RAC,之前居然一直没有了解过,独立开发的弊端,信息闭塞,而且自己也懒,这几天看了下RAC,确实很强大有木有. 什么是ARC 简单的说,RAC就是一个第三方库,他可以大 ...

  5. 百度编辑器 UEditor第一次加载后台数据失败

    给编辑器赋值的代码: var ue = UE.getEditor('content'); ue.ready(function (){      ue.setContent(data.data.cont ...

  6. JavaScript的for循环中嵌套一个点击事件为何点击一次弹出多个相同的值

    先看下面一段代码: for(var i=0; i<10; i++) { $('#ul').bind('click', function() { alert(i) }) } 对于这段代码,当点击I ...

  7. FineUIMvc随笔 - 不能忘却的回发(__doPostBack)

    声明:FineUIMvc(基础版)是免费软件,本系列文章适用于基础版. 用户反馈 有网友在官方论坛抛出了这么一个问题,似乎对 FineUIMvc 中的浏览器端与服务器端的交互方式很有异议. 这里面的关 ...

  8. 简单却又复杂的FizzBuzz面试编程问题

    写这篇文章主要是因为偶然看到一篇关于stackoverflow公司的面经中提到了一个有趣的面试编程问题,如题所述:FizzBuzz问题.原文引用如下: “在一些公平的考验之后,我发现那些因为代码而抓狂 ...

  9. js基础---cookie存储

    一.Cookie是什么Cookie是一种客户端(浏览器)把用户信息以文件形式存储到本地硬盘的技术,说白了就是一种浏览器技术 二.Cookie的作用Cookie的作用很单一,就是存储客户数据.(存储数据 ...

  10. mysql 局域网同事之间直接用客户端访问

    情景: 几个人作为小组开发一个项目,以我的机器为服务器,将mysql服务安装在我的机器上,其他小伙伴用客户端都能访问我这个数据库 解决:   首先: 1.设置mysql允许其它机器连接(linux环境 ...