博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Appium - iOS 各种问题汇总
阅读量:4578 次
发布时间:2019-06-08

本文共 4034 字,大约阅读时间需要 13 分钟。

 Appium - iOS 各种问题汇总

作者: Max.Bai

时间: 2014/10

Appium - iOS 各种问题汇总

 1. Appium 滑动:

 swipe 有三种方式:

 第一种:swipe

JavascriptExecutor js = (JavascriptExecutor) driver;WebElement  element = driver.findElementByXPath("xpath");HashMap
swipeObject = new HashMap
();swipeObject.put("startX", startX);swipeObject.put("startY", startY);swipeObject.put("endX", endX);swipebject.put("endY", endY);swipeObject.put("duration", duration);swipeObject.put("element", Double.valueOf(((RemoteWebElement) element).getId()));js.executeScript("mobile: swipe", swipeObject);

 

X,Y可为coordinator,也能够是percent,大于1 为coordinator。 小于1 为percent,比方0.5 代表50%

duration单位为秒, Android 能够设置0.1-60,iOS设置0.5-60

须要滑动特定的对象时须要指定的element。仅仅是在名目上滑动式就能够不指定element

另外一种: flick 差别swipe是没有duration

JavascriptExecutor js = (JavascriptExecutor) driver;WebElement  element = driver.findElementByXPath("xpath");HashMap
flickObject = new HashMap
();flickObject.put("startX", 0.8);flickObject.put("startY", 0.5);flickObject.put("endX", 0.2);flickObject.put("endY", 0.5);flickObject.put("element", Double.valueOf(((RemoteWebElement) element).getId()));js.executeScript("mobile: flick", flickObject);

第三种: scroll only for iOS scrollViewscroll方向滑动:

JavascriptExecutor js = (JavascriptExecutor) _driver;HashMap
scrollObject = new HashMap
();scrollObject.put("direction", sDrection); js.executeScript("mobile: scroll", scrollObject);
方向接受參数:Right, Left, Up, Down

重要:方向和我们觉得的方向相反。比方要向下滑,就用Up,应为Up的意思是滑动到手机的顶部,左右也是一样,左滑就是Right

scroll对象滑动:

JavascriptExecutor js = (JavascriptExecutor) driver;WebElement  element = driver.findElementByXPath("scrollview中元素的xpath");HashMap
scrollObject = new HashMap
();scrollObject.put("element", ((RemoteWebElement) element).getId());js.executeScript("mobile: scroll", scrollObject);

2. 隐藏键盘hideKeyboard()

为了避免输入框输入内容后键盘遮挡控件,须要对键盘隐藏

Android能够设置例如以下cap来输入中文,同一时候能达到隐藏键盘的效果,可是这个设置仅仅能针对Android。

capabilities.setCapability("unicodeKeyboard", true);capabilities.setCapability("resetKeyboard", true);
iOS 就必须掉用方法hideKeyboard()
默认是点非输入框的地方键盘自己主动隐藏。假设不生效(开发没有做这个效果),就须要使用其它方法,比方:通过点击“Done”来隐藏键盘
hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done");

3. Xcode 版本号

Appium 1.2.* 相应Xcode5.0

Appium 1.3  相应Xcode6.0
可能出现错误:
Error: Could not find Automation.tracetemplate
Error: Could not find ios simulator binary at /application/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator

mac 版本号更换命令,改动成自己版本号相应的路径就好了:

sudo xcode-select -switch /Applications/Xcode-4.6.app/Contents/Developer/

4. Sendkeys vs setValue

Sendkeys iOS无法输入

能够试用setvalue取代

((MobileElement)_driver.findElement(by)).setValue(sText);

5. isAppInstalled/removeApp/installApp

isAppInstalled这种方法在Android里面能够使用(模拟器和真机都试过)

可是在iOS里面使用模拟器返回值总是false,没有错误信息,后来查看源码发现
cb(new Error("You can not call isInstalled for the iOS simulator!"));
相同removeApp/installApp 都是

6. App path 设置

官网说能够用remote URL设置cap 的app

官网说明例如以下:
app    The absolute local path or remote http URL to an .ipa or .apk file, or a .zip containing one of these. Appium will attempt to install this app binary on the appropriate device first. e.g.: /abs/path/to/my.apk or http://myapp.com/app.ipa
我为了方便集中管理安装程序所以使用了http://sssss/x.zip
坑爹的问题来了,Android根本就不支持,报错找不到提供的app
iOS 还好,能够安装,可是測试中发现好多控件和放在本地全然不是一个效果。。。

所以还是老老实实的使用本地设置吧
ps: 貌似1.3攻克了Android http 的问题,还没有验证

7. sudo安装Appium后无法启动

sudo npm install -g appium后果

Appium will not work if used or installed with sudo
网上有高人攻克了这个问题
步骤例如以下:
步骤1. 改变node的全部者
cd /usr/local/lib
sudo chown -R bixiaopeng node_modules
步骤2. 卸载appium
npm uninstall appium -g
步骤3. 又一次安装appium
npm install -g appium
步骤4. 启动
appium
原链接:http://blog.csdn.net/wirelessqa/article/details/29188665

8. App or IPA ?

刚開始都想基于開始測试,发现怎么都是不行,无论App,和ipa格式的。如今我总结了一下分享给大家。

无论app的还是ipa的都要区分模拟器版本号和真机版本号

对于模拟器的,app的Appium不用解压,直接安装,ipa的Appium会解压找出app然后安装,问题来了,Appium用的解压工具是unzip。假设你的ipa里面包括中文的文件名称,预计要出问题了,这个是unzip的老问题,网上有方案。不在这里说了,最简单的就是使用app的包,不用解压。

对于真机的,眼下还没有測试,兴许有问题会更新。

转载于:https://www.cnblogs.com/zfyouxi/p/5149493.html

你可能感兴趣的文章
P2264 情书
查看>>
BZOJ 1004: [HNOI2008]Cards
查看>>
剪切板实现拖拽代码
查看>>
海量数据处理策略
查看>>
hello,world !
查看>>
【Entity Framework】Model First Approach
查看>>
C# DataTable删除行Delete与Remove的问题
查看>>
HDU2586How far away? LCA
查看>>
网络流 - 最大流
查看>>
随手记note(记事簿)
查看>>
JRE System Library 与Java EE Libraries的区别
查看>>
sqlite3性能优化要点
查看>>
颜色分类函数
查看>>
Oracle数据泵详解
查看>>
(中等) HDU 4725 The Shortest Path in Nya Graph,Dijkstra+加点。
查看>>
一个程序员的时间管理
查看>>
sort-归并排序
查看>>
django 快速实现完整登录系统(cookie)
查看>>
.NET中的out和ref关键字
查看>>
Python之ftp服务器
查看>>