iOS Interface automation Tool--appium

Source: Internet
Author: User

iOS Interface automation Tool--appium

Appium is an open source mobile end automation testing framework that supports Android and iOS, before simply introducing Appium, link http://www.yeetrack.com/?p=639. Recently in the automated testing of iOS, and then a detailed record of the process.

Installing Appium

Since the use of the Appium framework, installation is definitely necessary, two ways to install the source code, or directly install binary DMG files.

    • Source mode

        git clone https://github.com/appium/appium

      Once the download is complete, sh reset.sh it will be appium configured in the environment variables of our computer, directly using the Appium & boot. But this installation method, I did not find Appium Inspector This interface analysis tool. interface of the automated testing, if the tool is less, it is more tangled.

    • Binary Direct Install app package

      Appium updated the 1.3.1 version around 2014-10-20 and is more friendly to Xcode6 and iOS 8.1, and it is recommended to download this version. : https://github.com/appium/appium/releases, after the download installation is complete, the Appium icon should appear in the Mac application.

Installing Xcode

Since you are automating your iOS test, Xcode is best installed, although you can compile and package your iOS project from the command line build. Install Xcode and search for downloads directly from the Apple Store, Xcode version 6.1.

Sample Project

The sample project for direct run Appium is the quickest way to get started, Appium offers a variety of language versions of sample projects, including Android, Ios, Languages Java, PHP,. NET, JS, Perl, Python, Ruby. I've been using Java, and here's the Java language for example.

  1. Download code:git clone https://github.com/appium/sample-code.git
  2. Installing MAVEN, configuring environment variables
  3. Modify the configuration in the sample project

    Sample-code/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium/uicatalogtest.java

     @Before public void setUp() throws Exception {     // set up appium     File classpathRoot = new File(System.getProperty("user.dir"));     File appDir = new File(classpathRoot, "../../../apps/UICatalog/build/Release-iphonesimulator");     File app = new File(appDir, "UICatalog.app");     DesiredCapabilities capabilities = new DesiredCapabilities();     capabilities.setCapability(CapabilityType.BROWSER_NAME, "");     capabilities.setCapability("platformVersion", "7.1");     capabilities.setCapability("platformName", "iOS");     capabilities.setCapability("deviceName", "iPhone Simulator");     capabilities.setCapability("app", app.getAbsolutePath());     driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);     driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); }

    If you run with the emulator, you should not need to modify it (provided that you build the code at the command line, Xcodebuild), and the real machine needs to be modified to look like this:

     // set up appium //File classpathRoot = new File(System.getProperty("user.dir")); //File appDir = new File(classpathRoot, "../../../apps/UICatalog/build/Release-iphonesimulator"); String appName = "5LDV***BF.com.yeetrack.ios.app";  //注意修改成自己的应用,这块可以在Xcode中查看,实际上就是Xcode中的Bundle identifier这个参数 DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); capabilities.setCapability("platformVersion", "7.1.1");  //真机的ios版本 capabilities.setCapability("platformName", "iOS"); capabilities.setCapability("deviceName", "iPhone"); capabilities.setCapability("app", appName); driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
  4. Start the Appium service and execute it at the root path of the test project mvn clean mvn -Dtest=com.saucelabs.appium.UICatalogTest test .

Appium Inspector

In Android, we can use the powerful tool of Hierarchyviewer to analyze interface controls, see the control ID, name, type, and so on. In iOS if you want to analyze the interface controls, you can use Xcode to view them, or through Xcode's Uiautomator recorded JS script to see, but it is more troublesome. Appium provides us with the Inspector tool. Simple steps to use are as follows:

    1. Click on the "Apple" icon to set the relevant parameters, such as

      • App Path: Use the simulator to set this option to specify the build-out app, path such as:/Users/apple/work/workspace/sample-code/sample-code/apps/UICatalog/build/Release-iphonesimulator/UICatalog.app
      • Bundleid: Use the real machine to set this option, this is the bundle identifier in Xcode, this parameter, said once.
      • Force Device Select the type of machine to start
      • Platform version Specifies iOS versions
      • UDID use the true machine to set this option, which is the unique identity of the iphone and can be viewed using itune
      • Xcode path: Set the path to Xcode if you have more than one Xcode installed in your Mac where you can manually specify
    2. Click on the "Launch" icon to start Appium Server

    3. Click on the "Launch" to the left of the magnifying glass icon, you can start the Inspector tool, relatively slow, patient wait. After loading, you can view the interface control tree and record the script. When you click on a control, you can see the name, value, label, XPath, type, and so on for the control, and the current premise is that it is developed to define these things.
Problems encountered

Continue reading,

iOS Interface automation Tool--appium

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.