IOS滑动操作
来源:互联网 发布:淘宝买lol账号安全吗 编辑:程序博客网 时间:2024/05/22 02:13
Appium - iOS 各种问题汇总
时间: 2014/10
Appium - iOS 各种问题汇总
java-client从4.1.2升级到5.0.2,API中找不到swipe方法,应该是高版本的java-client舍弃了swipe
1. Appium 滑动:
swipe 有三种方式:
第一种:swipe
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put("startX", startX);
swipeObject.put("startY", startY);
swipeObject.put("endX", endX);
swipebject.put("endY", endY);
swipeObject.put("duration", duration);
swipeObject.put("direction", "left");
swipeObject.put("element", Double.valueOf(((RemoteWebElement) element).getId()));js.executeScript("mobile: swipe", swipeObject);
X,Y可为coordinator,也可以是percent,duration单位为秒, Android 可以设置0.1-60,iOS设置0.5-60
可以指定的element,也可以不指定
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> swipeObject = new HashMap<String, String>();
swipeObject.put("startX","80%");
swipeObject.put("startY","174");
//swipeObject.put("endX", "56");
swipeObject.put("endX","50%");
swipeObject.put("endY","0");
swipeObject.put("duration","1");
swipeObject.put("direction","left");
swipeObject.put("element", ((RemoteWebElement)el).getId()+"");
js.executeScript("mobile: swipe",swipeObject);
第二种: flick 区别swipe是没有duration
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> flickObject = new HashMap<String, Double>();
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 scrollView
scroll方向滑动:
JavascriptExecutor js = (JavascriptExecutor) _driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", sDrection);
js.executeScript("mobile: scroll", scrollObject);
方向接受参数:Right, Left, Up, Down
scroll对象滑动:
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement element = driver.findElementByXPath("scrollview中元素的xpath");
HashMap<String, String> scrollObject = new HashMap<String, String>();
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
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
- IOS滑动操作
- IOS手势操作:点击+滑动
- IOS手势操作:点击+滑动
- ios UITableView实现单击提示,滑动删除,多选行等操作
- IOS开发—手势操作(点击+滑动)
- iOS之UITableView带滑动操作菜单的Cell
- iOS学习笔记之TableViewCell右侧滑动多项操作
- ios UITableView实现单击提示,滑动删除,多选行等操作
- IOS中常用手势:手指向右滑动和向左滑动屏幕实现固定操作
- IOS中常用手势:手指向右滑动和向左滑动屏幕实现固定操作
- WebDriver 鼠标滑动操作
- 添加滑动条操作
- 滑动手势操作
- appium滑动操作
- mfc 滑动条操作
- ios 滑动swipe识别
- ios UIScrollView 循环滑动
- IOS 手指滑动删除
- spring事务传播属性,隔离级别
- 用.lng文件翻译成中文
- 自定义三级ratingbar
- Java (1-2)
- 二分查找
- IOS滑动操作
- cv conference paper search and download
- 视频的前景目标
- 关于php实例化过程的探究
- JQ 操作radio select 等
- C++ STL stack/queue的使用方法
- 拉钩异步数据抓取
- Mac下更新npm版本
- 数组常见算法比较