Appium使用

安装

https://www.jianshu.com/p/eec62494a5b0

使用前注意

  • 测试App在真机上调试满足以下几点:
    1.设置>开发者>Enable UI Automation 打开;
    2.源码导入Xcode;
    3.需要developer证书并且将测试机的udid 加入到pp(Provisioning Profile)文件,configruation为debug;
  1. 编译打包到终端;
    注:2〜4不会要可以找IOS开发人员帮助,本宝宝也是找开发解决的。
    5.工程中终端配置启动项
  • WebdriverAgent版本问题
    1、1.7.2 Appium Desktop
    需要替换 node_modules 目录下的 WebdriverAgent
    2、1.8.0 Appium Desktop
    不需要,直接将 webdriverAgent 安装到手机即可;

python脚本使用Tips

  • 模拟器启动基本代码(运行脚本前请先打开Appium服务)
from appium import webdriver
import pandas as pd
import time
desired_caps = {
    'deviceName': 'iPhone X', #模拟器名称
    'platformName': 'ios',
    'platformVersion': '11.2', #模拟器版本号,不是app的最低版本号
    'bundleId': 'com.galaxyentertainment.crmmobile'
}
# 真机需要一下这些
# desired_caps['bundleId'] = 'com.galaxyentertainment.crmmobile'     
# desired_caps['udid'] = 'f37a8a5e786b4ee728961a118591f43d50baa08d'
# desired_caps['xcodeOrgId'] = "填写你公司的开发者帐号"
# desired_caps['xcodeSigningId'] = "iPhone Developer"
# desired_caps['no-reset'] = True
# desired_caps['app'] = "/Users/woody/Downloads/DriverSide.ipa"
driver = webdriver.Remote(command_executor="http://127.0.0.1:4723/wd/hub", desired_capabilities=desired_caps)
脚本运行成功自动弹出页面.png
  • 演示-输入文本+点击按钮
# 获取ui控件(根据type)
# 设置用户名+密码
tfs = driver.find_element_by_class_name('TextField')

# 清空输入框,注意模拟器需要打开键盘弹出功能(cmd+k)
tfs.clear()
tfs.send_keys('ptr.wei.zou')

passwordTF = driver.find_element_by_class_name('XCUIElementTypeSecureTextField')
passwordTF.clear()
passwordTF.send_keys('Abcd12346!@#')

# 登录
driver.find_element_by_name('Login').click()

你可能感兴趣的:(Appium使用)