2018-02-07Appium1.3.2-IOS11-Xcod

2018-02-08  本文已影响0人  QA_man

第一次搭建IOS APPIUM自动化环境,仅供参考

appium android 通信分析


image.png

appium ios 通信分析


image.png

安卓手机系统设置,高能预警一定要记住,

以小米手机为例

  1. 打开开发者选项
  2. 开启USB调试
  3. 开启永不锁屏
  4. 开启USB安装权限
  5. 开启USB调试(安全设置)尤其是这一个,需要sim卡激活才能打开

IOS手机系统设置,高能预警一定要记住

  1. 打开开发者选项
  2. 通用-描述性文件与设备管理 :安装webdriveragent的时候需要证书认证开发者账号
  3. 开启永不锁屏
  4. 关于本机页面-》证书信任设置

环境准备

  1. 修改镜像源 npm install -g cnpm --registry=https://registry.npm.taobao.org
    appium下载较快。
  2. 安装appium :npm install -g appium 版本:服务版本1.6.2
  3. 下载客户端 appim.dmg: https://github.com/appium/appium-desktop/releases/tag/v1.3.2
    服务的版本号:Appium v1.7.2
    注意:网上下载 appium服务客户端最新版本1.3.2 appium.dmg ,如果下载pkg 会有问题导致找不到xcode版本
image.png
  1. Xcode 9.2 :升级到最新问题会少很多,编译安装WebDriverAgent,运行并安装WebDriverAgent服务,后边介绍如何安装运行
  2. 真机iPhone 6 Plus 系统 IOS 11.1版本,10系统可以不越狱
  3. 安装依赖包:
brew install --HEAD libimobiledevice   
brew install ideviceinstaller 
image.png
  1. 安装 imobiledevice :brew install imobiledevice做端口转发使用
    使用iproxy --help 可以查到更具体的用法。 ipproxy 8100 8100时通过访问http://localhost:8100/status确认WDA是否运行成功。
    而inspector的地址是http://localhost:8100/inspector, inspector是用来查看UI的图层,方便写测试脚本用的

  2. 安装node: brew install node

  3. Xcode 命令行工具 :终端输入xcode-select --install
    使用它在命令安装webdriveragent ,在mac Yosemite os10.10.X,可以单独安装命令行工具

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=$UDID" test
  1. 安装Appium-Python-Client: pip install Appium-Python-Client,否则报错import appium error
  2. appium client : npm install wd
  3. 设置ANDROID_HOME
  4. 设置JAVA_HOME
  5. appium-doctor检查必须全部通过


    image.png
  6. appium-doctor --ios 检查ios 环境必须通过


    image.png

配置 XCODE WebDriverAgent

cd  /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
ln -s WebDriverAgent WebDriverAgent

获取测试APP

git clone 测试app:https://github.com/zhshijie/appiumSimpleDemo
cd appiumSimpleDemo
命令:xcodebuild -sdk iphoneos -target appiumSimpleDemo -configuration Release

启动服务

image.png

测试用例

# -*- coding: utf-8 -*-

import sys,os
from appium import webdriver
sys.path.append('../../')
import unittest
from common.driver.android_driver import myDriver

class TrainTest(unittest.TestCase):

    def setUp(self):
        app=os.path.abspath('/Users/user/Documents/linan.wang/appiumSimpleDemo/build/Release-iphoneos/appiumSimpleDemo.app')
        self.driver =webdriver.Remote(
            command_executor='http://0.0.0.0:4327/wd/hub',
            desired_capabilities ={
                # 'app':app,
                'automationName':'XCUITest',
                'platformName':'ios',
                'platformVersion':'11.1',
                'deviceName':'iPhone 6 Plus',
                'bundleId':'com.cvte.appiumSimpleDemo.elonglinan',
                'udid':'d9b5803504e8873e8824cb98e1f1fb3e2a83a1ab'

            }
        )
    def test_push_view(self):
        next_view_button=self.driver.find_element_by_accessibility_id('entry next view')
        next_view_button.click()



if __name__ == '__main__':
    # suite=unittest.TestLoader().loadTestsFromTestCase('TrainTest')
    # unittest.TextTestRunner().run(suite)
    unittest.main()

常见报错:

  1. 报错:WebDriverException: Message: A new session could not be created. Details: Appium's IosDriver does not support xcode version 9.2. Apple has deprecated UIAutomation. Use the "XCUITest" automationName capability instead.
  1. 报错:WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Sdk '10.3' was not in list of simctl sdks
上一篇 下一篇

猜你喜欢

热点阅读