Appium is an open source cross-platform test automation tool for local, hybrid, and mobile web and desktop applications. Supports emulators (iOS, Android) and real devices (iOS, Android, Windows, Mac).

We recommend you to read the following articles first

IOS Automated Testing details kIF-based iOS UI automated testing and continuous integration

The preparation of the instruments

  • Xcode
  • PyCharm
  • Command Line Tool
  • HomeBrew, Node, NPM…

1. InstallHomebrew

Homebrew is a software management tool for MACOSX, or to put it crudely, something like ma’s qq software assistant. So you can install visual tools like Chrome browser and Atom editor via Brew.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Copy the code

2. InstallNode

  • 1. Download using Homebrew:

    brew install nodeCopy the code
  • 2. Or download the. PKG file from the official address

3. The installationnpm

NPM is an application/module management tool for the Node.js world, which means that NPM only manages applications that serve the JavaScript community. And cross-platform, as long as the Node environment, Windows and OSX, and other Unix-like operating systems are available. Skip this step if you do not need to start Appium on the cli.

  • Switch taobao image to install CNPM (for some reason, there will be a lot of network problems directly with NPM download installation, install Taobao CNPM is better than NPM):

    npm install -g cnpm --registry=https://registry.npm.taobao.orgCopy the code

4. Installation of Carthage

Similar to Cocoapods to manage third-party code, automatically compile projects into a dynamic library, only support iOS8 and above.

brew install carthageCopy the code

5. Install other tools

  • libimobiledeviceUse guide

    brew install libimobiledevice --HEADCopy the code
  • The IdeviceInstaller installs, uninstalls, and backs up applications on iOS devices. The tool is based on libMobileDevice, so you need to compile and install libMobileDevice first

    brew install ideviceinstallerCopy the code

    Ideviceinstaller does not support iOS10. Ios-deploy is a tool that uses the command line to install iosApp on connected devices. It invokes underlying system functions according to the OSX command line project, obtains connected devices, queries, installs, and uninstalls apps.

    cnpm install -g ios-deployCopy the code
  • Xcpretty is used to format the output of XcodeBuild without installation

    sudo gem install xcprettyCopy the code
  • App Inspector is a mobile DEVICE UI viewer running in a browser. It uses a tree state structure to view THE UI layout and automatically generates XPath for easy script writing and generation. Check the AppInspector usage

    cnpm install app-inspector -gCopy the code

6. Download Appium – Python – Client

  • Install PIP first

    sudo easy_install pipCopy the code

  • To install Appium – Python – Client

    sudo pip install Appium-Python-ClientCopy the code

7. DownloadappiumAnd appium – doctor

There are two ways to install Appium. One is to download and install appium using CNPM:

cnpm install -g appiumCopy the code
cnpm install -g appium-doctorCopy the code

Recommended!!! You can also download the Appium-desktop installation package, open the DMG package of Appium-Desktop, and copy appium. app to the Applications folder to complete the installation.

Configuration of 8.appium-xcuitest-driver

Appium-xcuitest-driver uses the WDA solution provided by Facebook to drive iOS testing

/ /! If the WebDriverAgent is in a different path, Find CD /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent // If you want to install appium-desktop, the path is CD /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgentCopy the code
mkdir -p Resources/WebDriverAgent.bundleCopy the code
sh ./Scripts/bootstrap.shCopy the code

The script downloads all dependencies using Carthage and packages the response JS files using NPM.

Cannot find module ‘eslint-config-appium’ :

sh ./Scripts/bootstrap.sh -dCopy the code

The screenshot of successful operation is as follows:

Here we go!!

If all else fails, please pull a copy of the latest WDA code from Github!

Git clone https://github.com/facebook/WebDriverAgent.git CD to WebDriverAgent sh. / Scripts/bootstrap. ShCopy the code

/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent Be sure to run successfully before you replace!

How to install WebDriverAgent on ios 10.3.3

9. Run appium-doctor to view the result

Appium -doctor info AppiumDoctor appium doctor v.1.4.3 info AppiumDoctor ### Diagnostic ### info AppiumDoctor searchability The Node.js binary was found at: /usr/local/bin/node info AppiumDoctor stocking node version is 8.9.4 info AppiumDoctor stocking Xcode is installed at: / Applications/Xcode. App/Contents/Developer info AppiumDoctor ✔ Xcode Command Line Tools are installed. The info AppiumDoctor Configure The Authorization DB to set up proper. info AppiumDoctor ➤ Carthage was found at: /usr/local/bin/carthage info AppiumDoctor ✔ HOME is set to: /Users/limaolin WARN AppiumDoctor * ANDROID_HOME is NOT set! WARN AppiumDoctor * JAVA_HOME is NOT set! WARN AppiumDoctor * adb could not be found because ANDROID_HOME is not set! WARN AppiumDoctor * Android could not be found because ANDROID_HOME is not set! WARN AppiumDoctor * Emulator could not be found because ANDROID_HOME is not set! WARN AppiumDoctor * Bin directory for $JAVA_HOME is not set info AppiumDoctor ### Completed, 6 fixes needed. ### info AppiumDoctor info AppiumDoctor ### Manual Fixes Needed ### info AppiumDoctor The configuration cannot be automatically fixed, please do the following first: WARN AppiumDoctor - Manually configure ANDROID_HOME. WARN AppiumDoctor - Manually configure JAVA_HOME. WARN AppiumDoctor  - Manually configure ANDROID_HOME and run appium-doctor again. WARN AppiumDoctor - Add '$JAVA_HOME/bin' to your PATH environment info AppiumDoctor ### info AppiumDoctor info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied! info AppiumDoctorCopy the code

10. Configure Android_HOME and JAVA_HOME

Download the recommended link of Android SDK Manager. After the download is successful, open the terminal, and enter CD to the tools directory of Android SDK (the Tools directory can be seen from the download. Drag the Tools directory after the CD to automatically complete the path).

Then enter the command./ Android SDK, SDK Manager pops up, as shown below:

vi ~/.bash_profileCopy the code

Add HOME path:

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
export CLASS_PATH=$JAVA_HOME/lib
export ANDROID_HOME=/usr/local/android-sdk-macosxCopy the code

Run the sources command:

source ~/.bash_profileCopy the code

Run appium-doctor again to see the result:

Info AppiumDoctor AppiumDoctor v.1.4.3 info AppiumDoctor ### Diagnostic Starting ### info AppiumDoctor ✔ ➤ The node.js binary was found at: /usr/local/bin/node info AppiumDoctor stocking node version is 8.9.4 info AppiumDoctor stocking Xcode is installed at: / Applications/Xcode. App/Contents/Developer info AppiumDoctor ✔ Xcode Command Line Tools are installed. The info AppiumDoctor Configure The Authorization DB to set up proper. info AppiumDoctor ➤ Carthage was found at: /usr/local/bin/carthage info AppiumDoctor ✔ HOME is set to: /Users/limaolin info AppiumDoctor ✔ ANDROID_HOME is set to: /usr/local/ android-sdK-macosx info AppiumDoctor ✔ JAVA_HOME is set to: / Library/Java/JavaVirtualMachines jdk1.8.0 _112. JDK/Contents/Home info AppiumDoctor ✔ adb exists at: /usr/local/android-sdk-macosx/platform-tools/adb info AppiumDoctor ✔ Android exists at: /usr/local/android-sdk-macosx/tools/android info AppiumDoctor ✔ emulator exists at: /usr/local/ android-sdK-macosx /tools/emulator info AppiumDoctor ✔ Bin directory of $JAVA_HOME is set info AppiumDoctor ### Diagnostic completed, no fix needed. ### info AppiumDoctor info AppiumDoctor Everything looks good, bye! info AppiumDoctorCopy the code

If not, enter terminal preferences:

/bin/bash

11. Compile WDA

WDA is at the heart of Appium automated testing.

Configure the BundleId and certificate correctly, and compile WebDriverAgentLib and WebDriverAgentRunner

CMD +U runs the test, or

cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent xcodebuild -project Webdriveragent. xcodeProj -scheme WebDriverAgentRunner -destination 'id= UDID 'test of the real machineCopy the code

FAQ 1:

FAQ 2:

Connection peer refused channel request for "dtxproxy:XCTestDriverInterface:XCTestManager_IDEInterface"; Canceled Failed to run tests: The operation couldn't be completed. (DTXProxyChannel error 1.)Copy the code

When it appears as follows:

ServerURL/status

iproxy 8100 8100
http://localhost:8100/status

http://localhost:8100/inspector

Inspector comes with WDA. The Appium-Desktop version has more features, can record scripts, and saves time in setting up an environment.

At this point, the Appium environment setup is basically complete.