Search code examples
androidrubyappium

Appium(Android) & Ruby slow to find element on an overlay


I am currently running some automation tests on Android using Appium and ruby however one step in the tests is extremely slow. What happens is that appium clicks on the menu button which drops down on top of the home screen. After this it looks for a button on the menu. At this point it becomes very slow. I can not search by text as there is text on the home screen which exactly matches the text on the button and I can not change this. As such, I am searching by the content-desc but this seems to take forever.

Is there any way to speed this up? Is there any way I can have appium only look at the overlay and ignore what is behind the overlay?

Here's an example of the appium log where it takes a long time.

[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 

Solution

  • just thought I'd update this. Found out that the slowness was being caused by animation so I just turned those off on the phone which has significantly sped up tests.