AppiumDesktop5.0.4 实现滑屏引导页

什么是AppiumDesktop
   有人说AppiumDesktop是Appium新版的叫法,也就是在Xcode8之前和之后的叫法。因为Xcode8之前自带的自动化测试框架叫做uiAutomation,Xcode8之后完全弃用了这一框架,
开始使用XCUITest,这导致Appium大修其下层机制,以使用Facebook的WebDriverAgen,也就是从这个时候在用Appium测试iOS应用的时候必须在iPhone手机上首先安装一个
应用叫:WebDriverAgentRunner。也就是通过这个应用来启动我们被测应用。



以上这段载自
作者:会做饭的厨子
链接:http://www.jianshu.com/p/bf1ca3d4ac76
来源:简书
 
APPIUM的api
http://appium.github.io/java-client/     最新版本已经更新到6.0.0-beta啦

由于首次安装APP,需要划过引导页,查了很多资料,都是老的APPIUM使用方式,使用swipe函数,但是通过新的API文档,可以查看到swpie函数已经在文档中查不到了,没错!
APPIUM-DESKTOP取消了swipe(),那么使用什么代替呢?
通过API的查找,我们找到了TouchAction,但是我们可以看到TouchAction,不再是swipe那么智能,只能一步步调用模拟真实用户的操作动作来实现滑动页面的效果。
(当然不排除也有类似swipe的函数,只是我没找到)


实现步骤:

按住屏幕一个点press->moveto屏幕另一个点->释放->执行以上的动作

然鹅,然鹅!在我测试过程中出现了一下问题,看看各位看官遇没遇到吧,自我记录一下!


问题1:
java代码部分

  int width=driver.manage().window().getSize().width;   //获取屏幕最大宽度
   int height=driver.manage().window().getSize().height; //获取屏幕最大高度
   WebElement fisrtpage=driver.findElementByClassName("android.widget.FrameLayout");
   new TouchAction(driver).press(firstpage,width*3/4,height/2).moveTo(width/4,height/2).release().perform();


              
异常:这里我是结合testng框架写的,所以报错体现在testng输出控制台里)

eclipse:
org.openqa.selenium.interactions.InvalidCoordinatesException: The coordinates provided to an interactions operation are invalid. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds

Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'

导致原因:
 new TouchAction(driver).press(firstpage,width*3/4,height/2).moveTo(width/4,height/2).release().perform();



org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error occured while starting App. Original error: 'com.dongao.kaoqian.phone.views.WelcomeActivity' never started (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 84.59 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z


导致原因:
new TouchAction(driver).press(width*3/4,height/2).moveTo(firstpage,width/4,height/2).release().perform();


解决:

原来这里发现press函数,使用两个座标点方法错误,如果press里增加了webelement同样对应的后面的moveto函数,也要加上webelement
当然有时也会遇到,都不增加webelement,报以上错误,所以建议,都加上webelement

--------------------------------------------------------------------我是分割线------------------------------------------------------------------------


问题2:
java代码部分

 int width=driver.manage().window().getSize().width;   //获取屏幕最大宽度
 int height=driver.manage().window().getSize().height; //获取屏幕最大高度
 WebElement fisrtpage=driver.findElementByClassName("android.widget.FrameLayout");
 new TouchAction(driver).press(fisrtpage,width*3/4,height/2).moveTo(fisrtpage,width/4,height/2).release().perform();
异常:
eclipse


org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'

appium
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.

解决:
如果报上述错误,在press和moveto中间增加等待功能,由于每一次机器响应时间,并不是每次都报错,建议增加上。
new TouchAction(driver).press(fisrtpage,width*3/4,height/2).waitAction(Duration.ofMillis(1000)).moveTo(fisrtpage,width/8, height/2).release().perform();


综述:
新改版的appiumdesktop,取消了swipe函数对于我们用户还说实在是操作不方便,当然也有可能有其他函数代替,我没找到,如果有,请您留言给我(也许英语限制了我的眼界可怜)
当然appiumdesktop也有新增了两大功能,便于用户操作,
1.可以界面获取元素,同android自带的uiautomatorviewer一样,但是AppiumDesktop可以定位iOS和Android两个操作系统的App
2.可以录制Python或Java脚本
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章