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腳本
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章