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)
  • 演示-輸入文本+點擊按鈕
# 獲取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()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章