Build iOS WebDriverAgent environment on Mac

Mac environment construction

  • macOS system computer: 12.6.2

  • Xcode:14.0.1(xcodebuild -version

  • appium Desktop: 1.21.0 ( download link )
    Appium Desktop 1.22.0 , starting from this version, Appium separates the Server and Inspect tools, which need to be downloaded separately.

  • Python:3.9

  • PyCharm

  • Install nodejs on mac

    check: npm -v,node -v

  • cnpm:npm install -g cnpm --registry=https://registry.npm.taobao.org

  • ios-deploy dependent library:cnpm install -g ios-deploy

  • brew:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

  • Install libimobiledevice, carthage:

    brew install libimobiledevice

    brew install carthage


Configure Xcode to generate WDA

  1. About the choice of WebDriverAgent

    1. appium-webdriveragentAfter installing Appium (or Appium Server GUI), a directory exists under the installation path
    2. Or download from github. For example, I tried appium/WebDriverAgent and selected the latest WebDriverAgent-4.10.23 at this time , and click to download directly: Source code(tar.gz) . Then replace the path underappium-webdriveragent

    path:

     # 如果安装的是新的 Appium Server GUI
     /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent
    
     # 如果安装的是 Appium 
     /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent
    
  2. Enter appium-webdriveragentthe directory and double-click WebDriverAgent.xcodeprojto open the project configuration

  3. Add a developer account

    Xcode->Preferences->Accounts, for personal use, the account needs to be purchased, and the general company will provide the account.

  4. select emulator

    On the top bar of Xcode, click WebDriverAgentRunner to select, as shown in the picture in the next step, I chose iPhone12, and the iOS version is 14.3.

  5. configurationWebDriverAgentLib

    insert image description here

  6. configurationWebDriverAgentRunner

    Need to change the Bundle Identifier, the original default is to com.facebook.WebDriverAgentRunneradd some random characters at the end to make it unique
    insert image description here

  7. WebDriverAgentRunnerSelect the emulator (or real device) that will run

    WebDriverAgent: WebDriverAgentRunner > iPhone12

  8. Shortcut key command + uRun and test

    • Xcode prompts Succeeded to indicate success
    • After the emulator is opened, a white WebDriverAgentapplication will be generated on the interface-
      insert image description here

common problem

brew install failed

Installation failed due to network problems, solution: command:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

( Solve reference links that cannot be installed )

If it is not a network problem, brew install libimobiledevicethe installation fails, promptingError: command failed with exit 128: git

Try reinstalling brew the most primitive way:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Also see a method:brew install --HEAD libimobiledevice

Guess you like

Origin blog.csdn.net/qq_31362767/article/details/129164973