美文网首页
Appium for Mac安装

Appium for Mac安装

作者: Maj_sunshine | 来源:发表于2019-01-08 11:33 被阅读18次
    1 安装brew

    安装brew

    curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1
    

    安装后执行

    brew
    
    brew update
    
    2 安装node.js
    brew install node
    
    3 安装JDK
    4 安装Android studio
    5 安装appium最新版本
    • 前往github
    • 下载最新dmg文件
    6 安装appium-doctor
    • 更新淘宝镜像,不然下载速度太慢
    npm config set -g registry https://registry.npm.taobao.org
    
    • 安装appium-doctor
    npm install -g appium-doctor
    
    7 配置环境变量,在终端下编辑/etc/profile文件
    • 赋予当前用户权限
    sudo chmod -R 777 /etc/profile
    
    • 查看保存jdk安装路径
    /usr/libexec/java_home -V
    
    屏幕快照 2018-12-24 上午9.34.33.png
    • 编辑文件
    vim ~/.bash_profile
    
    • 加入,注意改变jdk的安装路径
    export ANDROID_HOME=/Users/maj/Downloads/android-sdk-macosx
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home #jdk安装路径
    export PATH=~/bin:$PATH:/usr/local/bin:$ANDROID_HOME/platform-tools/:$JAVA_HOME/bin
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    
    • 打开appium,点击Edit configurations
      屏幕快照 2018-12-24 下午1.42.34.png
    • 第一个为sdk安装路径,一般为/Users/maj/Downloads/android-sdk-macosx,第二个为jdk安装路径.可以去终端输入/usr/libexec/java_home -V查看
    8 安装其他项目

    1、安装libimobiledevice(用于获取 iOS 设备信息)

    brew install libimobiledevice --HEAD
    

    若出现


    屏幕快照 2018-12-24 上午10.06.33.png

    则是因为libimobiledevice出现更新

    执行下面命令安装

    brew update
    brew uninstall --ignore-dependencies libimobiledevice
    brew uninstall --ignore-dependencies usbmuxd
    brew install --HEAD usbmuxd
    brew unlink usbmuxd
    brew link usbmuxd
    brew install --HEAD libimobiledevice
    

    2、安装carthage(项目依赖管理,WebDriverAgent 使用)

    brew install carthage
    

    3、安装ios-deploy(查看设备应用)

    npm install -g ios-deploy
    
    9 查看组件是否齐全
    appium-doctor
    
    屏幕快照 2018-12-24 下午1.46.00.png
    10 配置Appium中的WebDriverAgent

    1、 前往WebDriverAgent目录

    cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/WebDriverAgent 
    

    2、执行脚本

    ./Scripts/bootstrap.sh
    

    3、用xcode打开WebDriverAgent.xcodepro工程

    4、配置WebDriverAgentLib和WebDriverAgentRunner的证书

    屏幕快照 2018-12-24 下午3.59.04.png
    5、这里有个巨坑,请确认你的连接方式不是无线连接,不然怎么测试都是test failure,点击Product->Test
    6 运行成功后,可以看到ip地址,
    屏幕快照 2018-12-24 下午4.38.29.png
    11 Appium客户端基本配置
    image.png
    参数 描述 例子
    automationName 你想使用的自动化测试引擎 XCUITest -- iOS
    platformName 操作系统 iOS, Android
    platformVersion 手机版本 12.1
    deviceName 使用的手机或模拟器类型 iPhone Simulator, iPad Simulator, iPhone Retina 4-inch, Android Emulator, Galaxy S4
    app 本地或者远程app /Users/maj/Desktop/ipa/CloudEdge/Today/CloudEdge-release.ipa
    browserName 测试的浏览器名称 Safari
    newCommandTimeout 命令超时时间 30
    autoLaunch Appium是否需要自动安装和启动应用 true, false
    language 语言设置 iOS只对模拟器有用。 fr
    locale 时区设置 fr_CA, CA
    udid 设备udid a168fc4adf8116341c44897ad7057e8cf63a17d9
    orientation 指定方向测试 LANDSCAPE (横向) ,PORTRAIT (纵向)
    autoWebview 直接切换网页上下文 true, false
    noReset 开启回话要不要重启应用 true, false
    fullReset (iOS) 删除整个模拟器目录 true, false
    eventTimings appium内部事件是否报告 默认false
    enablePerformanceLogging 仅限网页开启Chromedriver true, false
    printPageSourceOnFindFailure 当查找操作失败时,打印当前页面源 true, false

    iOS特有

    参数 描述 例子
    calendarFormat 日期格式 gregorian
    bundleId 应用ID,这个可以不给,但是必须要有udid io.appium.TestApp
    udid 设备udid 1ae203187fc012g
    launchTimeout 启动超时时间(单位为毫秒) 20000
    locationServicesEnabled 定位是否开启(Sim-only) true
    locationServicesAuthorized 是否可以弹出定位服务警报 true or false
    autoAcceptAlerts 如果弹出,则自动接受所有iOS系统权限弹窗,不适用于基于XCUITest的测试 true or false
    autoDismissAlerts 是否字段关闭iOS的系统权限弹窗 true or false
    nativeInstrumentsLib 使用本机intruments库 true or false
    nativeWebTap 在Safari中启用“真实的”非基于JavaScript的网络点击(Sim-only) true or false
    safariInitialUrl 初始网页页面,默认为本地欢迎页面(Sim-only) https://www.github.com
    safariAllowPopups 允许javascript在Safari中打开新窗口(Sim-only) true or false
    safariIgnoreFraudWarning 防止Safari显示欺诈性网站警告(Sim-only) true or false
    safariOpenLinksInBackground Safari是否应允许在新窗口中打开链接 true or false
    keepKeyChains 是否在启动/完成appium会话时保留keychains true or false
    localizableStringsDir 在哪里寻找可本地化的字符串 en.lproj
    processArguments Arguments to pass to the AUT using instruments -myflag
    interKeyDelay 元素点击的延迟 100
    showIOSLog iOS的日志 true or false
    sendKeyStrategy 用于在文本字段中键入test的策略 oneByOne, grouped or setValue
    screenshotWaitTimeout 等待生成屏幕截图的最大超时秒数 10
    waitForAppScript 用于确定应用程序是否已启动的ios自动化脚本 true;, target.elements().length > 0;, $.delay(5000); true;
    webviewConnectRetries 将连接消息发送到远程调试器以获取webview的次数 默认值:8
    appName app display name UICatalog
    customSSLCert 为模拟器添加SSL 认证 -----BEGIN CERTIFICATE-----MIIFWjCCBEKg...-----END CERTIFICATE-----
    webkitResponseTimeout WebKit的响应时间(真机有效) 默认为5000

    相关文章

      网友评论

          本文标题:Appium for Mac安装

          本文链接:https://www.haomeiwen.com/subject/jecfxqtx.html