Configuring the Appium+android Automated test environment on Mac OSX

Source: Internet
Author: User
Tags appium

Prerequisite Preparation

Before you start the text, you need to prepare some basic conditions:

    1. devices that have Mac OS OS installed
    2. A way to access resources outside of China's local area network (no, but painful)
    3. The homebrew has been installed.
    4. The python3.x has been installed.
    5. Java Runtime environment is already installed.
Install Android STUDIO/SDK

The main purpose of this article is to test the Android app, so here we need to install Android studio or the Android SDK.

    • Android Studio-Complete development and testing tools that require ladders
    • Android SDK-enough to complete automated tests, install via homebrew

If it's just for automated testing I recommend installing the SDK enough, using the brew command.

brew install android-sdk

In the domestic use of brew can be configured in advance domestic sources, the speed will be much faster.

If there is a ladder recommended to choose Android Studio, the installation method is very simple, the official website after the download of the next, the launch will let you put the SDK and so a series of dependencies are installed, one step.

The actual Android studio is better, one step, can be installed in the SDK, etc., the Android Studio installation process will appear after the proxy error, click Cancel here, then installed, open, in the SDK manager set up the agent

The Android SDK updates the mirror server resources online:

Dalian Neusoft Institute of Information Mirror server address:
-http://mirrors.neusoft.edu.cn Port: 80
Beijing University mirror server address:
-ipv4:http://ubuntu.buct.edu.cn/Port: 80
-ipv4:http://ubuntu.buct.cn/Port: 80
-ipv6:http://ubuntu.buct6.edu.cn/Port: 80
Shanghai GDG Mirror server address:
-Http://sdk.gdgshanghai.com Port: 8000

The first one to be useful

Prepare an Android emulator or use a real machine

If the SDK is already installed, you should be able to use the ADB command to check the available emulators or the physical phone that is already connected to your computer.

adb devices

If you don't know where the ADB tool is, you can search through find at the command line first.

find /Users -name adb  # 搜索用户目录find / -name adb  # 搜索全盘

After you find it, you can add the ADB directory to the path for later use.

Installing Appium

Appium can be installed in a variety of ways.

Method One: Install with NodeJS

First install the Nodejs via brew:

brew install node

Configure a domestic source, create a new. npmrc file in the personal directory, write:

registry=https://registry.npm.taobao.org/

To start installing Appium:

install -g appiumnpm install -g appium-doctor

Appium-doctor can help you diagnose the test environment and recommend installation.

Mode II: Download Appium Desktop installation

The official Appium Desktop installation package can be downloaded from GitHub and requires a ladder.

    • Https://github.com/appium/app ...

Download the DMG file to double-click Mount, drag the Appium into the application to complete the installation.

Installing Appium-client

This article only discusses the Python implementation of the Appium test, so you only need to allow the following commands:

pip install Appium-Python-Client

If you already have Appium-doctor installed, you can just run the Appium-doctor command to know which environment variables you need to set.
[email protected] ~> appium-doctorinfo appiumdoctor appium Doctor v.1.4.3info appiumdoctor # # # Diagnostic Starting # # #info Appiumdoctor? The node. JS binary was found at:/usr/local/bin/nodeinfo appiumdoctor? Node version is 7.10.0info appiumdoctor? Xcode is installed at:/applications/xcode.app/contents/developerwarn appiumdoctor? Xcode Command Line Tools is not installed!info appiumdoctor? Devtoolssecurity is Enabled.info appiumdoctor? The Authorization DB is set up properly. WARN appiumdoctor? Carthage is not found!info appiumdoctor? HOME is set to:/users/tobyqininfo appiumdoctor? Android_home is set to:/users/tobyqin/library/android/sdk/info appiumdoctor? Java_home is set to:/library/java/javavirtualmachines/jdk1.8.0_112.jdk/contents/homeinfo AppiumDoctor? ADB exists at:/users/tobyqin/library/android/sdk/platform-tools/adbinfo appiumdoctor? Android exists at:/users/tobyqin/library/android/sdk/tools/androidinfo appiumdoctor? Emulator exists at: /users/tobyqin/library/android/sdk/tools/emulatorinfo appiumdoctor? Bin Directory of $JAVA _home is SetInfo appiumdoctor # # Diagnostic completed, 2 fixes needed. # # #info Appiumdoctorinfo appiumdoctor # # # Manual Fixes Needed # # #info Appiumdoctor The configuration cannot be automatical Ly fixed, please do the following First:warn appiumdoctor-please install Carthage. Visit https://github.com/Carthage/Carthage#installing-carthage for more information.info appiumdoctor # # #info Appiumdoctorinfo Appiumdoctor bye! Run Appium-doctor again when all manual fixes has been applied!

In fact you don't necessarily have to pass all the checks, if only to complete the Android Appium test, just make sure that android_home and Java_home are properly configured, and that the SDK tools and platform tools are basically completed by joining path. You can refer to the. Bash_profile settings in my personal directory:

Export Android_home=~/library/android/sdk/export java_home=/library/java/javavirtualmachines/jdk1.8.0_112.jdk/ Contents/homeexport path=~/bin: $PATH:/usr/local/bin: $ANDROID _home/platform-tools/: $JAVA _home/bin

  

Start writing automated Tests
From appium Import webdriverdesired_caps = {}desired_caps[' platformname '] = ' Android ' desired_caps[' platformversion '] = ' 7.1.1 ' desired_caps[' devicename '] = ' Android Emulator ' desired_caps[' apppackage '] = ' Com.android.dialer ' desired_caps [' appactivity '] = ' dialtactsactivity ' driver = webdriver. Remote (' Http://localhost:4723/wd/hub ', desired_caps) driver.find_element_by_id (' Com.android.dialer:id/search_box _collapsed '). Click () Search_box = driver.find_element_by_id (' Com.android.dialer:id/search_view ') Search_box.click ( ) Search_box.send_keys (' Hello Toby ')

  




Configuring the Appium+android Automated test environment on Mac OSX

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.