IOS App自动化测试环境配置 - Selenium2.0+Appium

5 篇文章 0 订阅
5 篇文章 0 订阅

(注:项目是HP的,客户在美国,配置文档是给客户看的,所以用的E文,也懒得翻译了,见谅)
Test Environment
Mac and IOS environment
Mac mini: OS X 10.10.3
IOS devices: iPhone 5S 8.0

Software environment
JDK 1.8.25
XCode 6.3
Appium 1.3.7
HP ePrint IOS App 5.7.0.181

Apple developer accountrequirement
IOS Develop Permission. $99 per year.

Xcode Account Setup
Create a developer account onApple web site, and then login Xcode with the account.
Xcode -> Preferences -> Accounts -> Click ‘+’ toadd a new account -> Add the developer account.
这里写图片描述

Apple Developer Certificates
这里写图片描述
这里写图片描述

Download the certificates and save it into local disk. It’scertSigningRequest type file.

Create App ID.
Input any string in App ID Description failed, select “WildcardApp ID”, input “com.hp.*” in bund ID field, and then click Continue save it.
The App ID means a project name, so the created App IDshould matches the tested iOS app bundle ID, but we cannot create the explicitApp ID, such as ePrint “com.hp.com.HPePrintHome-n-Biz”, So we need create awildcard App ID, such as “com.hp.*”, it means the App ID works for all the iOSapp which bundle ID’s prefix is “com.hp.”.
这里写图片描述

iOS device Setup
Select device tab and click “+” button, create device Nameand input the UUID and save it.
Get UUID from Xcode, open Xcode -> Window -> Devices-> select the connected device via USB, the Identifier is the UUID.
这里写图片描述

Generate ProvisioningProfiles.
Click “+” button to open “Add iOS Provisioning Profile”page. Select “iOS App development”and click “Continue”.
这里写图片描述

Select the created App ID just now and click “Continue”.
这里写图片描述

Select the created certificates just now and click “Continue”.
这里写图片描述

Select the new registered iOS device and click “Continue”
这里写图片描述

Create a profile name and click “Generate” button.
这里写图片描述

Download the provisioning profile and save it into localdisk.
这里写图片描述

Re-sign IOS App
1) First extract HPePrint.app fromHPePrint.ipa
2) Generate “entitlements.plist”file and put it into the app folder.
The file contents should be, and open the file correct with Xcode.

<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC"-//Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plistversion="1.0">
<dict>
  <key>get-task-allow</key>
  <true/>
</dict>
</plist>

这里写图片描述

3) Use the below command to re-sign the app.
Open a terminal and go to the app folder, execute below command.

codesign -f -s "iPhone Developer: XXXX" ./HPePrint.app/ResourceRules.plist HPePrint.app --entitlements entitlements.plist

这里写图片描述
The parameter “iPhone Developer: XXXX” can be found inKeychain Access.
这里写图片描述

Appium and iOS Device Setup.
1) iOS setup
iOS device –> settings -> Developer -> Turn on “EnableUI Automation” option
这里写图片描述
2) Install provisioning profileand re-signed app into iOS device.
Open Xcode -> Window -> devices -> click settingbutton below and open “Show Provisioning Profiles”
这里写图片描述
Click “+” to add the provisioning profile into the iOSdevice.
这里写图片描述
Return device window and click “+” to select the re-signedapp and install it into device.
这里写图片描述
3) Appium setup
这里写图片描述
The parameter BundleID can be found in Xcode.
这里写图片描述

Launch Appium Inspector
Open Appium -> click Start -> click Appium Inspector
Environment was ready if the Appium inspector launchedsuccessfully in Mac and the App launched successfully in iOS device.
这里写图片描述


Appium是一个开源的自动化测试框架,主要用于移动应用的UI测试,特别是跨平台的iOS和Android应用程序。它利用WebDriver协议来控制实际设备或模拟器,Python是Appium的一种常用语言接口之一,因为它易于编写和理解。 使用Appium + Python进行iOS应用自动化测试的步骤主要包括: 1. 安装依赖:首先确保你已经在本地环境中安装了Python、Appium服务器(通过`npm install -g appium`)以及相关的Python库,如`selenium-python`(用于与Appium交互)和`appium-python-client`(用于与Appium服务进行通信)。 2. 配置Appium:在服务器端配置一个iOS模拟器或真机,指定使用的操作系统版本、设备名称等信息。你需要在Appium的偏好设置中配置对应的SDK路径和必要的证书。 3. 创建测试脚本:用Python编写测试脚本,通过`selenium.webdriver.Remote()`创建一个WebDriver实例,并连接到Appium服务器。例如: ```python from appium import webdriver desired_caps = {'platformName': 'iOS', 'platformVersion': '14.5', 'deviceName': 'iPhone 12', 'app': '/path/to/your.app'} driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) ``` 4. 测试逻辑:使用Python的selenium库编写测试用例,包括启动应用、点击元素、输入文本、检查元素状态等操作。执行完毕后记得调用`driver.quit()`关闭会话。 5. 运行测试:运行Python脚本,Appium将根据脚本的指令控制iOS应用的行为,执行测试并返回结果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值