zoukankan      html  css  js  c++  java
  • appium(1)-about appium

    about appium

    Introduction to Appium

    Appium is an open-source tool for automating native, mobile web, and hybrid applications on iOS and Android platforms.//测试移动端应用,包括安卓和苹果平台的原生、移动web、混合应用。

    • 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 or the built-in ‘Browser’ app on Android).
    • Hybrid apps have a wrapper around a “webview” – a native control that enables interaction with web content. 

    Importantly, Appium is “cross-platform”: it allows you to write tests against multiple platforms (iOS, Android), using the same API. This enables code reuse between iOS and Android testsuites.//测试代码可以在安卓和苹果两个平台复用。

    We use vendor-provided automation frameworks under the hood.That way, we don’t need to compile in any Appium-specific or third-party code or frameworks to your app.The vendor-provided frameworks we use are://使用系统提供的测试接口,iOS的UIAutomation和Android的UiAutomator。

    • iOS 9.3 and below: Apple’s UIAutomation//appium1.5及其以前版本支持
    • iOS 9.3 and up : Apple's XCUITest//appium1.6及其以后版本支持。
    • Android 4.2+: Google’s UiAutomator
    • Android 2.3+: Google’s Instrumentation. (Instrumentation support is provided by bundling a separate project, Selendroid)

    We wrap the vendor-provided frameworks in one API, the WebDriver API. WebDriver (aka “Selenium WebDriver”) specifies a client-server protocol (known as the JSON Wire Protocol). Given this client-server architecture, a client written in any language can be used to send the appropriate HTTP requests to the server.//使用WebDriver(webdriver是web端测试时涉及到的一个协议,把客户端代码翻译成浏览器可以识别的代码)。

    Appium Concepts

    Client/Server Architecture
    Appium is at its heart a webserver that exposes a REST API. It receives connections from a client, listens for commands, executes those commands on a mobile device, and responds with an HTTP response representing the result of the command execution. The fact that we have a client/server architecture opens up a lot of possibilities: we can write our test code in any language that has a http client API, but it is easier to use one of the Appium client libraries. We can put the server on a different machine than our tests are running on. We can write test code and rely on a cloud service like Sauce Labs to receive and interpret the commands.//cs结构,客户端和服务器端的交互遵循REST API风格,由此带来两个好处,一是客户端可以使用任意编程语言,二是服务器端与客户端可以不在一个机器上。

    Session
    Automation is always performed in the context of a session. Clients initiate a session with a server in ways specific to each library, but they all end up sending a POST /session request to the server, with a JSON object called the ‘desired capabilities’ object. At this point the server will start up the automation session and respond with a session ID which is used for sending further commands.//自动化的所有操作都是在一个session基础上完成的。

    Desired Capabilities
    Desired capabilities are a set of keys and values (i.e., a map or hash) sent to the Appium server to tell the server what kind of automation session we’re interested in starting up. There are also various capabilities which can modify the behavior of the server during automation. For example, we might set the platformName capability to iOS to tell Appium that we want an iOS session, rather than an Android one. Or we might set the safariAllowPopups capability to true in order to ensure that, during a Safari automation session, we’re allowed to use JavaScript to open up new windows. See the capabilities doc for the complete list of capabilities available for Appium.//一些键值对,可以决定session的类型,比如是建立一个iOS session,还是一个Android session。

    Appium Server
    Appium is a server written in Node.js. It can be built and installed from source or installed directly from NPM: $ npm install -g appium $ appium //用Node.js语言写成的一个服务端。

    Appium Clients
    There are client libraries (in Java, Ruby, Python, PHP, JavaScript, and C#) which support Appium’s extensions to the WebDriver protocol.//支持多种语言。

    Language/FrameworkGithub Repo and Installation Instructions
    Ruby https://github.com/appium/ruby_lib
    Python https://github.com/appium/python-client
    Java https://github.com/appium/java-client
    JavaScript (Node.js) https://github.com/admc/wd
    Objective C https://github.com/appium/selenium-objective-c
    PHP https://github.com/appium/php-client
    C# (.NET) https://github.com/appium/appium-dotnet-driver
    RobotFramework https://github.com/jollychang/robotframework-appiumlibrary

    Appium Platform Support

    iOS Requirements

    iOS Support

    See Running on OS X: iOS for iOS requirements and setup instructions.

    • Versions: 7.1, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1 and 9.2
    • Devices: iPhone Simulator, iPad Simulator, and real iPhones and iPads
    • Native app support: Yes, with debug version of .app (simulator), or correctly-signed .ipa (real devices). Underlying support is provided by Apple’s UIAutomation framework.
    • Mobile web support: Yes, via automation of mobile Safari. For real devices, ios-webkit-remote-debugger is required, and automation of native aspects of the Safari interface is not possible. See the mobile web doc for instructions.
    • Hybrid support: Yes. For real devices, ios-webkit-remote-debugger is required. See the hybrid doc for instructions.
    • Support for automating multiple apps in one session: No
    • Support for automating multiple devices simultaneously: No
    • Support for automating vendor-provided or third-party apps: Only vendor-provided apps (Preferences, Maps, etc…), and only on the simulator
    • Support for automating custom, non-standard UI controls: Minimal. You need to set accessibility information on the control which enables some basic automation.

    Android Requirements

    • Android SDK API >= 17 (Additional features require 18/19)
    • Appium supports Android on OS X, Linux and Windows. Make sure you follow the directions for setting up your environment properly for testing on different OSes:

    Android Support

    See Running on OS X: Android, Running on Windows, or Running on Linux for Android requirements and setup instructions.

    • Versions: 2.3 and up//支持安卓版本2.3及其以上。
      • Versions 2.3 through 4.2 are supported via Appium’s bundled version of Selendroid, which utilizes Instrumentation. Selendroid has a different set of commands than the default Appium (though this is rapidly being minimized) and a different support profile. To access this automation backend, use the automationName capability with the value Selendroid.
      • Versions 4.2 and up are supported via Appium’s own UiAutomator libraries. This is the default automation backend.
    • Devices: Android emulators and real Android devices//支持仿真机和实体机。
    • Native app support: Yes//支持原生应用、移动端web应用和混合应用。
    • Mobile web support: Yes (but not when using Selendroid backend). Automation is effected using a bundled Chromedriver server as a proxy. With 4.2 and 4.3, automation works on official Chrome browser or Chromium only. With 4.4+, automation also works on the built-in “Browser” app. Chrome/Chromium/Browser must already be installed on the device under test. See the mobile web doc for instructions.
    • Hybrid support: Yes. See the hybrid doc for instructions.
      • With default Appium automation backend: versions 4.4 and up
      • With Selendroid automation backend: versions 2.3 and up
    • Support for automating multiple apps in one session: Yes (but not when using the Selendroid backend)//在一个session可以操作多个应用。
    • Support for automating multiple devices simultaneously: Yes, though Appium must be started using different ports for the server parameters --port, --bootstrap-port (or --selendroid-port) and/or --chromedriver-port. See the server args doc for more information on these parameters.//通过配置不同端口号来操作多台设备。
    • Support for automating vendor-provided or third-party apps: Yes (but not when using the Selendroid backend)
    • Support for automating custom, non-standard UI controls: No

    Difference between device and emulator

    Appium on real Android devices

    Hooray! There’s nothing extra to know about testing real Android devices: it works exactly the same as testing on emulators. Make sure that your device can connect to ADB and has Developer Mode enabled. For testing Chrome on a real device, you’re responsible for ensuring that Chrome of an appropriate version is installed.//测试时,真机和模拟器没啥不一样

    Appium on real iOS devices

    Appium has support for real device testing.//测试时,真机和模拟器太多不一样

    To get started on a real device, you will need the following:

    • An Apple Developer ID and a valid Developer Account with a configured distribution certificate and provisioning profile.
    • An iPad or iPhone. Make sure this has been set up for development in Xcode. See this article for more information.
    • A signed .ipa file of your app, or the source code to build one.
    • A Mac with Xcode and the Xcode Command Line Developer Tools.

    Provisioning Profile:A valid iOS Development Distribution Certificate and Provisioning Profile are necessary to test on a real device. Your app will also need to be signed. You can find information about this in the Apple documentation.

    Appium will attempt to install your app using Fruitstrap, but it is often easier to pre-install your app using Xcode to ensure there are no problems (see the iOS deploy doc for more information).

     

    Testing using Xcode 8 (including iOS 10) with XCUITest:This functionality currently depends on logging based on idevicesyslog, and port forwarding based on iProxy, both of which are part of libimobiledevice. Install it with Homebrew,

    brew install libimobiledevice
    

    Alternatively, logging can be done using deviceconsole, which is available here. To choose between them, use the desired capability realDeviceLogger, passing in the path to the logging program.

     

    Running your tests with Appium:Once your device and app are configured, you can run tests on that device by passing the -U or --udid flag to the server or the udid desired capability, and the bundle ID (if the app is installed on the device) or the path to the .ipa or .apk file via the --app flag or the app desired capability.

     

    Server Arguments:For example, if you are prelaunching your app and wish for Appium to force use a specific UDID, then you may use the below command:

    appium -U <udid> --app <path or bundle>

    This will start Appium and have Appium use the device to test the app.

    Refer to the Appium server arguments page for more detail on the arguments that you can use.

     

    Desired Capabilities:You can launch the app on a device by including the following desired capabilities in your tests:

    • app
    • udid

    Refer to the Appium server capabilities page for more detail on the capabilities that you can use.

     

    Troubleshooting ideas

    1. Make sure UDID is correct by checking it in Xcode Organizer or iTunes. It is a long string (20+ chars).
    2. Make sure that you can run your tests against the Simulator.
    3. Double check that you can invoke your automation from Instruments.
    4. Make sure Instruments is not already running.
    5. Make sure UI Automation is enabled on your device. Settings -> Developer -> Enable UI Automation
  • 相关阅读:
    一点一点学ASP.NET之基础概念——HttpModule
    Repeater为空时显示处理
    数据绑定控件的ItemDataBound事件与System.Data.Common.DbDataRecord
    Fckeditor编辑器添加【行距】
    gridview用法大全(二)
    Web.config自定义节点configSections
    C#中的特性(Attributes)(翻译)
    给程序员的忠告
    项目管理(转载)
    在ASP.NET 2.0中使用样式、主题和皮肤(转载)
  • 原文地址:https://www.cnblogs.com/superbaby11/p/6053542.html
Copyright © 2011-2022 走看看