Mac下appium ios自动化测试(一)

mac下ios自动化测试,可以使用appium,也可以直接用facebook-wda库。

此篇先介绍appium:

开始之前先要知道测试app的bundleId,这是ios特有的。可以采用如下命令:

ideviceinstaller -l

遇到问题:

Could not connect to lockdownd. Exiting.

解决办法:

打开命令行一次输入如下代码:

brew uninstall ideviceinstaller -g
brew uninstall libimobiledevice -g
brew install --HEAD libimobiledevice -g
brew install ideviceinstaller -g
sudo chmod -R 777 /var/db/lockdown

问题解决。

如果还有问题   

brew install --HEAD ios-webkit-debug-proxy -g

brew install ios-webkit-debug-proxy -g

当然如果上述还是没有解决你的问题那么下面的绝对能解决:

brew uninstall -f libimobiledevice ideviceinstaller usbmuxd
brew install -v --HEAD --fresh --build-from-source usbmuxd libimobiledevice ideviceinstaller

第1步:开启server端

前一篇有介绍,我是安装的命令行版,采用命令行启动:

/usr/local/bin/appium -a 127.0.0.1 -p 4723 -bp 4724

第2步:运行测试脚本

如下实例:

#! /usr/bin/env python
#coding=utf-8

import time,os
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction


driver = webdriver.Remote(command_executor='http://127.0.0.1:4723/wd/hub',
                               desired_capabilities={
                               'bundleId': 'com.lifesense.LSWearable.iusexxx',
                               'platformName': 'iOS',
                               'platformVersion': '10.3',
                               'deviceName': 'sandyiPhone',
                               "automationName": "XCUITest",
                               "noReset": False,
                               "udid": "11c7b654ae4c7b1bb43d456c5e5e7fxxxxxxxx"
                               })

time.sleep(5)
driver.find_element_by_name("请输入手机号码").send_keys("13148536426")
driver.tap([(30,95),[30,98]],500)
driver.find_element_by_accessibility_id("账号密码登录").click()
#el2.click()
el3 = driver.find_element_by_xpath(
    "//XCUIElementTypeApplication[XCUIElementTypeSecureTextField")
el3.send_keys("123456")
driver.tap([(30,95),[30,98]],500)
el4 = driver.find_element_by_accessibility_id("登录")
el4.click()

 元素定位请参考inspector使用篇

猜你喜欢

转载自www.cnblogs.com/Sandy-1128/p/sandy1128-mac-appiumiostest.html