美文网首页Full Stack DeveloperiOS
Appium+iOS+Mac 环境搭建

Appium+iOS+Mac 环境搭建

作者: samtake | 来源:发表于2019-02-14 15:41 被阅读60次

Appium+iOS+Mac环境搭建

直接选择安装桌面版本 Download Appium
通过命令行配置主要的工具环境,只针对iOS
# Get the Facebook Tap.
brew tap facebook/fb
# Install fbsimctl from master
brew install fbsimctl --HEAD
链接参考

Appium Getting Started
The XCUITest Driver for iOS

appium-doctor 安装
npm install appium-doctor -g
查看iOS相关配置是否完整
appium-doctor --ios 
如果提示Xcode没有安装执行
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
WebDriverAgent 更换
  • 执行 ./Scripts/bootstrap.sh
  • 直接用Xcode打开WebDriverAgent.xcodepro文件
  • 配置WebDriverAgentLib和WebDriverAgentRunner的证书
  • 连接并选择自己的iOS设备,然后按Cmd+U,或是点击Product->Test
  • 运行成功时,在Xcode控制台应该可以打印出一个Ip地址和端口号
  • 在浏览器上输入上一步骤的网址,如果打印出一些json格式的信息,说明运行成功。
  • 将该WebDriverAgent整个目录替换Appium安装时的自带的WebDriverAgent,具体目录查看为/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/WebDriverAgent
支持python环境 Appium Python Client
brew install python
sudo chmod 777 /Library/Python/2.7/site-packages/
git clone git@github.com:appium/python-client.git 
cd python-client

python setup.py install
测试文件

import unittest
import os
from appium import webdriver
from time  import sleep


class  appiumSimpleTezt (unittest.TestCase):

    def  setUp(self):
        app = os.path.abspath('脚本打包的ipa目录')

        self.driver = webdriver.Remote(
            command_executor = 'http://127.0.0.1:4723/wd/hub',
            desired_capabilities = {
                'app':app,
                'platformName': 'iOS',
                'platformVersion': '12.0',
                'deviceName': 'iOS',
                'bundleId': '程序的bundleId',
                'udid': '真机的uuid(在Xcode的Window->Devices中获取)'
            }
            )

    def test_Login(self):
        
        #权限弹框
        self.driver.switch_to.alert.accept()
        self.driver.switch_to.alert.accept()
        sleep(1)
        #输入用户名及密码进行登录操作
        user_phone = self.driver.find_elements_by_name(name="输入手机号码")
        for phone in user_phone:
            phone.click()
            phone.send_keys("15219335287")
        user_password = self.driver.find_elements_by_name(name="输入密码")
        for pw in user_password:
            pw.click()
            pw.send_keys("abc123456")
        sleep(1)
        # 隐藏键盘
        keyboard_hide = self.driver.find_element_by_accessibility_id("Toolbar Done Button")
        keyboard_hide.click()
        #点击登录
        login_button = self.driver.find_element_by_accessibility_id("登录")
        login_button.click()
        sleep(1)
    def tearDown(self):
        sleep(1)

        # self.driver.quit()

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(appiumSimpleTezt)
    unittest.TextTestRunner(verbosity=2).run(suite)

测试文件放在项目根目录下,直接运行命令即可。
python OFRiderTest.py
命令行打包ipa

没有用pod时直接运行就可以了

xcodebuild -sdk iphoneos -target  [targetname]  -configuration Release
用到pod时
xcodebuild -list
xcodebuild -scheme  [shemename] -workspace [xxx.xcworkspace绝对路径] build
打包ipa时的位置.png
通过appium定位元素
{
  "bundleId": "bundleId",
  "automationName": "XCUITest",
  "platformName": "iOS",
  "platformVersion": "12.0",
  "udid": "uuid",
  "deviceName": "苹果手机名字"
}
配置.png

相关文章

  • Appium+iOS+Mac 环境搭建

    Appium+iOS+Mac环境搭建 直接选择安装桌面版本 Download Appium 通过命令行配置主要的...

  • Appium Python Client

    在上篇Appium+iOS+Mac 环境搭建的基础上,复制翻译了Appium Python Client以作为后续...

  • React Native学习总结篇

    一、环境搭建 1.1 React Native环境搭建 1.1.1 IOS环境搭建 环境:MacOS 注意:不要使...

  • linux 第四天

    Lamp环境搭建 /*******************Lamp环境搭建:*******************...

  • codePush说明

    codePush环境搭建 环境搭建文章:环境搭建 git地址:codePush git地址2.0.3,And...

  • angular学习--02英雄指南

    环境搭建 angular官网--搭建本地开发环境和工作空间windows 10 搭建angular开发环境免搭建环...

  • Gradle开发-Groovy环境搭建

    ##Groovy环境搭建 在使用 Groovy 之前首先要搭建几个环境: Groovy 的环境搭建 JDK 环境搭...

  • 搭建 LNMP + CodeIgniter 开发环境

    搭建 LNMP + CodeIgniter 开发环境搭建 LNMP 环境首先搭建 LNMP 的服务器环境安装 Ng...

  • iOS中RN与Flutter混合开发

    一 搭建环境 1. 搭建flutter环境 1.1 搭建系统开发环境 参考链接:https://flutter....

  • 第一个MyBatis程序

    思路:搭建环境---导入MyBatis--编写代码---测试! 一、搭建环境 1、搭建数据库环境: engine=...

网友评论

    本文标题:Appium+iOS+Mac 环境搭建

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