zoukankan      html  css  js  c++  java
  • Appium简介及工作原理

    一、什么是Appium

    Appium是一个开源、跨平台的测试框架,可以用来测试原生及混合的移动端应用。Appium支持IOS、Android及FirefoxOS平台。Appium使用WebDriver的json wire协议,来驱动Apple系统的UIAutomation库、Android系统的UIAutomator框架。Appium对IOS系统的支持得益于Dan Cuellar’s对于IOS自动化的研究。Appium也集成了Selendroid,来支持老android版本。

    Appium支持Selenium WebDriver支持的所有语言,如java、Object-C、JavaScript、Php、Python、Ruby、C#、Clojure,或者Perl语言,更可以使用Selenium WebDriver的Api。Appium支持任何一种测试框架。如果只使用Apple的UIAutomation,我们只能用javascript来编写测试用例,而且只能用Instruction来运行测试用例。同样,如果只使用Google的UIAutomation,我们就只能用java来编写测试用例。Appium实现了真正的跨平台自动化测试。

    appium选择了client-server的设计模式。只要client能够发送http请求给server,那么的话client用什么语言来实现都是可以的,这就是appium及webdriver如何做到支持多语言的;

    下面这段介绍来自于appium的官网。

    Appium is an open-source tool you can use to automate mobile native, mobile web, and mobile hybrid applications on iOS and Android platforms. “Mobile native apps” are those written using the iOS or Android SDKs. “Mobile web apps” are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome on Android). “Mobile hybrid apps” have a native wrapper around a “webview” – a native control that enables interaction with web content. Projects like Phonegap, for example, make it easy to build apps using web technologies that are then bundled into a native wrapper – these are hybrid apps. Importantly, Appium is “cross-platform”: it allows you to write tests against multiple platforms (iOS, Android), using the same API. This enables a large or total amount of code reuse between iOS and Android testsuites.

    二、Appium的工作原理

    2.1 Android

    在Android端,appium基于WebDriver协议,利用Bootstrap.jar,最后通过调⽤用UiAutomator的命令,实现App的自动化测试。

    UiAutomator测试框架是Android SDK自带的App UI自动化测试Java库。

    另外由于UiAutomator对H5的支持有限,appium引入了chromedriver以及safaridriver等来实现基于H5的自动化。

    appium 在android端工作流
    1. client端也就是我们 test script是我们的webdriver测试脚本。

    2. 中间是起的Appium的服务,Appium在服务端起了一个Server(4723端口),跟selenium Webdriver测试框架类似, Appium⽀持标准的WebDriver JSONWireProtocol。在这里提供它提供了一套REST的接口,Appium Server接收web driver client标准rest请求,解析请求内容,调⽤用对应的框架响应操作。

    3. appium server会把请求转发给中间件Bootstrap.jar ,它是用java写的,安装在手机上.Bootstrap监听4724端口并接收appium 的命令,最终通过调⽤用UiAutomator的命令来实现。

    4. 最后Bootstrap将执行的结果返回给appium server。

    5. appium server再将结果返回给 appium client。

    2.2 ios

    在IOS端,appium同样使⽤WebDriver的一套协议。

    与Android端测试框架不同的是,appium ios封装了apple的 Instruments框架,主要用了Instrument里的UI Automation(Apple的⾃自动化测试框架),然后在设备中注⼊入bootstrap.js进⾏行监听。

    appium 在ios端工作流
    1. client端 依然是 test script是我们的webdriver测试脚本。

    2. 中间是起的Appium的服务,Appium在服务端起了一个Server(4723端口),跟selenium Webdriver测试框架类似, Appium⽀持标准的WebDriver JSONWireProtocol。在这里提供它提供了一套REST的接口,Appium Server接收web driver client标准rest请求,解析请求内容,调⽤用对应的框架响应操作。

    3. appium server调用instruments.js 启动⼀一个socket server,同时分出一个⼦子进程运⾏instruments.app,将bootstrap.js(一个UIAutomation脚本)注⼊入到device⽤于和外界进行交互

    4. 最后Bootstrap.js将执行的结果返回给appium server

    5. appium server再将结果返回给 appium client。

    所以我们可以看到android与ios区别在于appium 将请求转发到bootstrap.js或者bootstrap.jar.然后由bootstrap 驱动UIAutomation和UiAutomator去devices上完成具体的动作。

  • 相关阅读:
    Java多线程问题
    pattern-matching as an expression without a prior match -scala
    从Zero到Hero,OpenAI重磅发布深度强化学习资源
    What-does-git-remote-and-origin-mean
    flink source code
    如何生成ExecutionGraph及物理执行图
    rocketmq 源码
    Flink source task 源码分析
    flink 获取上传的Jar源码
    fileupload
  • 原文地址:https://www.cnblogs.com/feifei-cyj/p/7905798.html
Copyright © 2011-2022 走看看