Appium searches for element by it's id in every fourth attempt


#1

Hi,

Currently I am automating an android application. When running the appium script the element is serached by it’s id (self.driver.find_elements_by_id) in every fourth attempt. Here is the server logs.

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[RESOURCE_ID=com.abc.tiq.sense.test:id/stream_event_column1]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[RESOURCE_ID=com.abc.tiq.sense.test:id/stream_event_column1]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0)
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=com.abc.tiq.sense.test:id/stream_event_column1]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (1)
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=1, RESOURCE_ID=com.abc.tiq.sense.test:id/stream_event_column1]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (2)
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=2, RESOURCE_ID=com.abc.tiq.sense.test:id/stream_event_column1]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:[{“ELEMENT”:“3”},{“ELEMENT”:“4”}]}
[AndroidBootstrap] Received command result from bootstrap
[W3C (8bcc5cca)] Responding to client with driver.findElements() result: [{“element-6066-11e4-a52e-4f735466cecf”:“3”,“ELEMENT”:“3”},{“element-6066-11e4-a52e-4f735466cecf”:“4”,“ELEMENT”:“4”}]
[HTTP] <-- POST /wd/hub/session/8bcc5cca-314f-49cd-a5fa-416557b7c1fb/elements 200 30558 ms - 127
[HTTP]
[HTTP] --> GET /wd/hub/session/8bcc5cca-314f-49cd-a5fa-416557b7c1fb/element/3/attribute/text
[HTTP] {}
[W3C (8bcc5cca)] Calling AppiumDriver.getAttribute() with args: [“text”,“3”,“8bcc5cca-314f-49cd-a5fa-416557b7c1fb”]
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getAttribute”,“params”:{“attribute”:“text”,“elementId”:“3”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getAttribute”,“params”:{“attribute”:“text”,“elementId”:“3”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getAttribute
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:"[0]:196.291\n[0]:191.782\n[0]:186.597\n[0]:190.882"}

Best,
Saswat


#2

Sounds like you need to wait for the elements to render:

https://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp