2016-10-04 139 views
0

我目前正在使用Appium和ruby在Android上運行一些自動化測試,但是測試中的一個步驟非常緩慢。會發生什麼是appium點擊主屏幕頂部的菜單按鈕。之後它會在菜單上尋找一個按鈕。此時它變得非常緩慢。我無法通過文本進行搜索,因爲主屏幕上的文本與按鈕上的文本完全匹配,我無法更改此文本。因此,我正在通過content-desc進行搜索,但這似乎要花上一段時間。Appium(Android)&Ruby在疊加層上查找元素很慢

有什麼辦法可以加快速度嗎?有沒有什麼辦法可以讓appium只看覆蓋圖而忽略覆蓋圖的背後?

下面是一個需要很長時間的appium日誌的例子。

[HTTP] --> POST /wd/hub/session/9d9d5814-2085-4f25-bb5e-e4cc0838fa25/elements {"using":"id","value":"Performances button"} 
[MJSONWP] Calling AppiumDriver.findElements() with args: ["id","Performances button"... 
[debug] [BaseDriver] Waiting up to 0 ms for condition 
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"Performances button","context":"","multiple":true}} 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"Performances button","context":"","multiple":true}} 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'Performances button' using 'ID' with the contextId: '' multiple: true 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[RESOURCE_ID=uk.co.bbc.music:id/Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[RESOURCE_ID=uk.co.bbc.music:id/Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0) 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=uk.co.bbc.music:id/Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[RESOURCE_ID=android:id/Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[RESOURCE_ID=android:id/Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0) 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=android:id/Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[DESCRIPTION=Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[DESCRIPTION=Performances button] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0) 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[DESCRIPTION=Performances button, INSTANCE=0] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (1) 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[DESCRIPTION=Performances button, INSTANCE=1] 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[{"ELEMENT":"11"}]} 
[debug] [AndroidBootstrap] Received command result from bootstrap 
[MJSONWP] Responding to client with driver.findElements() result: [{"ELEMENT":"11"}] 
[HTTP] <-- POST /wd/hub/session/9d9d5814-2085-4f25-bb5e-e4cc0838fa25/elements 200 80730 ms - 90 
+0

你在使用find_elements還是driver.find_element(id =>「your id」)? – archon92

+0

我有一個查找元素函數,其中包含以下內容:if(is_android) \t \t#按資源ID(僅限Android)搜索。 \t \t元素= $ driver.find_elements(:ID,ELEMENT_NAME) \t \t如果(elements.size()> 0) \t結果=要素[0] \t \t \t返回結果 \t \t端 \t end' 這是需要很長的時間。 – sohaib

回答

1

只是想我會更新這個。發現慢動作是由動畫引起的,所以我只是在手機上關掉了那些明顯加速測試的手機。