2016-10-04 145 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

只是想我会更新这个。发现慢动作是由动画引起的,所以我只是在手机上关掉了那些明显加速测试的手机。