环境准备

  • brew install carthage
  • npm i -g ios-deploy
  • brew install libimobiledevice --HEAD
  • brew install ideviceinstaller
  • 使用brew安装时,如果出现update home brew 直接control C退出更新

iOS平台的特殊性:

  • 封闭

    • 系统封闭
    • 应用分发渠道封闭,仅限app store;
    • 软件和硬件绑定,例如iOS测试只能使用mac
  • 文档稀少 封闭导致的
  • 行业交流少,网上关于自动化测试的

主流移动测试框架

  • Calabash-iOS 需要被测应用的源码才能测试
  • XCTest 苹果主推的,用的人少,但基于XCTest的框架却很多
  • Earl Grey && KIF 谷歌开发的单元测试框架,需要程序源码,基于XCTest
  • WebDriverAgent Facebook推出的,基于XCtest,不需要源码。WDA是一个http服务器。
  • Appium 是一个代理
  • Ui automation(在Xcode8后废弃)

测试环境准备

  • 启动WDA

    • 切换到WebDriverAgent目录下,先执行bootstrap.sh脚本 ./Scripts/bootstrap.sh
    • Xcode打开WDA,product -test
  • iproxy 8100 8100
  • 启动Appium服务,使用放大镜Start Inspector Session
    • 在capability中输入以下配置,启动session
    {
"platformName": "iOS",
"automationName": "XCUITest",
"usePrebuiltWDA": true,
"deviceName": "iPhone",
"udid": "",
"bundleId": "",
"newCommandTimeout":600
}

注意:

1.查看应用的报名: ideviceinstaller -l

2.查看本机IP: iconfig en0

3.安装应用: ideviceinstall -i *.ipa

4.查看手机udid: idevice_id -l

5.启动时,要选择Automatic Server,不要选择Custom Server

6.newCommandTimeout类型选择number,不要选择text。

使用appium提供的工程测试

appium提供的example:https://github.com/appium/ios-uicatalog
打开终端,将代码克隆下来 git clone https://github.com/appium/ios-uicatalog
xcode打开,product-run,将应用安装到手机
也可以使用build将工程打成app,如果打成app,要查找app导出目录
#python
#coding:utf-8
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python from appium import webdriver
import time caps = {}
caps["platformName"] = "iOS"
caps["automationName"] = "XCUITest"
caps["deviceName"] = "iPhone"
caps["udid"] = "527a084d6010b8179658ddeb5295428d1973cfa6"
caps["bundleId"] = "com.example.apple-samplecode.UICatalogcsj815379479"
caps["newCommandTimeout"] = 600 driver = webdriver.Remote("http://localhost:4723/wd/hub", caps) el1 = driver.find_element_by_xpath("(//XCUIElementTypeButton[@name=\"More Info\"])[1]")
el1.click()
el2 = driver.find_element_by_accessibility_id("Okay / Cancel")
time.sleep(2)
el2.click()
el3 = driver.find_element_by_accessibility_id("OK")
try:
assert el3.text=='OK','button not OK'
except AssertionError as e:
print(e)
driver.quit()

2. 使用Appium录制生成脚本


recorder里为记录的脚本

```
#python
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

from appium import webdriver

from time import sleep

caps = {}

caps["platformName"] = "iOS"

caps["deviceName"] = "iphone"

caps["bundleId"] = "com.taobaobj.moneyshield"

caps["automationName"] = "XCUITest"

caps["udid"] = "527a084d6010b8179658ddeb5295428d1973cfa6"

caps["newCommandTimeout"] = "600"

caps["usePrebuiltWDA"] = True

driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)

sleep(3)

el1 = driver.find_element_by_accessibility_id("工具箱")

el1.click()

el2 = driver.find_element_by_accessibility_id("诈骗举报")

el2.click()

el3 = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@name="电话诈骗举报"]")

el3.click()

el4 = driver.find_element_by_xpath("//XCUIElementTypeApplication[@name="钱盾"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther[1]")

el4.send_keys("13693347586")

el5 = driver.find_element_by_xpath("(//XCUIElementTypeImage[@name="radiobox_normal"])[3]")

el5.click()

el6 = driver.find_element_by_accessibility_id("请简要描述一下诈骗来电的内容,比如来电时间,对方特征,被骗方式等")

el6.send_keys("骗子,大骗子")

el7 = driver.find_element_by_accessibility_id("诈骗内容")

el7.click()

el8 = driver.find_element_by_accessibility_id("提交举报")

el8.click()

6-3-1appium iOS的更多相关文章

  1. iOS可视化动态绘制连通图

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  2. 【疯狂造轮子-iOS】JSON转Model系列之二

    [疯狂造轮子-iOS]JSON转Model系列之二 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇<[疯狂造轮子-iOS]JSON转Model系列之一> ...

  3. 【疯狂造轮子-iOS】JSON转Model系列之一

    [疯狂造轮子-iOS]JSON转Model系列之一 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 之前一直看别人的源码,虽然对自己提升比较大,但毕竟不是自己写的,很容易遗 ...

  4. iOS总结_UI层自我复习总结

    UI层复习笔记 在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是 ...

  5. iOS代码规范(OC和Swift)

    下面说下iOS的代码规范问题,如果大家觉得还不错,可以直接用到项目中,有不同意见 可以在下面讨论下. 相信很多人工作中最烦的就是代码不规范,命名不规范,曾经见过一个VC里有3个按钮被命名为button ...

  6. JS调用Android、Ios原生控件

    在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...

  7. 告别被拒,如何提升iOS审核通过率(上篇)

    iOS审核一直是每款移动产品上架苹果商店时面对的一座大山,每次提审都像是一次漫长而又悲壮的旅行,经常被苹果拒之门外,无比煎熬.那么问题来了,我们有没有什么办法准确把握苹果审核准则,从而提升审核的通过率 ...

  8. Swift3.0服务端开发(一) 完整示例概述及Perfect环境搭建与配置(服务端+iOS端)

    本篇博客算是一个开头,接下来会持续更新使用Swift3.0开发服务端相关的博客.当然,我们使用目前使用Swift开发服务端较为成熟的框架Perfect来实现.Perfect框架是加拿大一个创业团队开发 ...

  9. Summary of Critical and Exploitable iOS Vulnerabilities in 2016

    Summary of Critical and Exploitable iOS Vulnerabilities in 2016 Author:Min (Spark) Zheng, Cererdlong ...

  10. 黑云压城城欲摧 - 2016年iOS公开可利用漏洞总结

    黑云压城城欲摧 - 2016年iOS公开可利用漏洞总结 作者:蒸米,耀刺,黑雪 @ Team OverSky 0x00 序 iOS的安全性远比大家的想象中脆弱,除了没有公开的漏洞以外,还有很多已经公开 ...

随机推荐

  1. 第三视角团队:"Jarvis For Chat"团队选题报告

    "Jarvis For Chat"团队选题报告 组长博客链接 本次作业链接 NABCD在项目中的使用 N(Need,需求) QQ和微信已经成为人们社交的必需品,在QQ有7.8亿活跃 ...

  2. iOS工程中如何去掉第三方的警告

    一)第一种方法 在工程中有警告的地方,右键选择Review in log,然后就能看到类似[Wnonnull]这样的警告, 然后在工程buildSettings中的Other Warning Flag ...

  3. vmware Esxi 回收Thin模式磁盘空间

    本文来自:https://blog.csdn.net/happyfreeangel/article/details/85075179 第一部分 回收Thin模式磁盘空间背景:在使用Thin模式的磁盘, ...

  4. Android 源码阅读之SMS,MMS

    主界面: com.android.mms.ui.ConversationList.java  [extends ListActivity] 点击新建信息:onListItemClick -〉 posi ...

  5. 触电(by quqi99)

    高压电线杆相关的触电方式主要是两种: 一是跨步电压,高压电线落在地面时,如果人恰好在这个范围内步行时,就会从一只脚到跨下再到另一只脚到地形成回路,这叫跨步电压.步子越大,电压越大(以落地点为圆心向外电 ...

  6. H - 【59】Lazier Salesgirl 模拟//lxm

    Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling ...

  7. Centos中查看系统信息的常用命令

    系统日志文件(可以通过cat或tail命令来查看) /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 /var/log/secure 与安全 ...

  8. 安装SharePoint Server的主机重命名

    今天我头脑一热, 把安装在WS 2008 R2上的有Stand-alone SharePoint Server 2010的机器重命名了一下, 结果SharePoint Central Admin都进不 ...

  9. OK335xS Linux Qt make: icpc: Command not found

    OK335xS Linux Qt make: icpc: Command not found 一.出错现象: make: icpc: Command not found make: *** [main ...

  10. 20155207 2006-2007-2 《Java程序设计》第5周学习总结

    20155207 2006-2007-2 <Java程序设计>第5周学习总结 教材学习内容总结 第八章 语法与继承架构 Java中的错误以对象方式呈现为 java.lang.Throwab ...