Android: The page is scrolled down when trying to access an element located at the top of the page

Hello,
I’m trying to understand a bit what’s happening in my android tests. The issue is that I am trying to access the first edit text on a registration screen. When the screen is reached, the page is scrolled down, so that the element couldn’t be found anymore.

However, if I “help” appium by manually scrolling the page, the edit text field is found and the test passes.

Here are two videos uploaded with the problem:

  1. Without manually scrolling the screen: https://www.youtube.com/watch?v=wivOD0UjR3w
  2. Helping appium by manually scrolling the screen to the top: https://www.youtube.com/watch?v=wivOD0UjR3w

I am using Java client v2.1.0, Appium server V1.3.1 and also genymotion emulator running Android 4.3 API 18(also tried Android 4.4.4 API 19)

Does anyone have any clue here? :slight_smile:

Are you using scrollTo() function. or this occurred without doing so?

Thanks,
Priyank Shah

I am NOT using any scrollTo() method.
only have:

driver.findElement(By.id(“register.firstName.placeholder”)).sendKeys(“blabla”);

Can you provide the appium server log?

1 Like

Here it is:

info: --> POST /wd/hub/session/718c98fd-4193-4956-b2f6-769422a5859d/elements {"using":"id","value":"register.firstName.placeholder"}
info: [debug] Waiting up to 15000ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"register.firstName.placeholder","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"register.firstName.placeholder","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding register.firstName.placeholder using ID with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=register.firstName.placeholder]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=register.firstName.placeholder]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=register.firstName.placeholder, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=First Name]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=First Name]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=First Name, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (1)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=First Name, INSTANCE=1]
info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"4"}],"sessionId":"718c98fd-4193-4956-b2f6-769422a5859d"}
info: <-- POST /wd/hub/session/718c98fd-4193-4956-b2f6-769422a5859d/elements 200 1549.686 ms - 89 {"status":0,"value":[{"ELEMENT":"4"}],"sessionId":"718c98fd-4193-4956-b2f6-769422a5859d"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[{"ELEMENT":"4"}],"status":0}
info: --> POST /wd/hub/session/718c98fd-4193-4956-b2f6-769422a5859d/elements {"using":"name","value":"First Name"}
info: [debug] Waiting up to 15000ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"First Name","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"First Name","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding First Name using NAME with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=First Name]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=First Name]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=First Name, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=First Name]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=First Name]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=First Name, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (1)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=First Name, INSTANCE=1]
info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"5"}],"sessionId":"718c98fd-4193-4956-b2f6-769422a5859d"}
info: <-- POST /wd/hub/session/718c98fd-4193-4956-b2f6-769422a5859d/elements 200 166.554 ms - 89 {"status":0,"value":[{"ELEMENT":"5"}],"sessionId":"718c98fd-4193-4956-b2f6-769422a5859d"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[{"ELEMENT":"5"}],"status":0}
info: --> POST /wd/hub/session/718c98fd-4193-4956-b2f6-769422a5859d/element/4/value {"id":"4","value":["BlaBla"]}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"4","text":"BlaBla","replace":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"4","text":"BlaBla","replace":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Updating class "class com.android.uiautomator.core.UiDevice" to enable field "mUiAutomationBridge"
info: [debug] [BOOTSTRAP] [debug] Updating class "class com.android.uiautomator.core.UiAutomatorBridge" to enable field "mInteractionController"
info: [debug] [BOOTSTRAP] [debug] Finding methods on class: class com.android.uiautomator.core.InteractionController
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"UiSelector[TEXT=First Name, INSTANCE=0]"},"sessionId":"718c98fd-4193-4956-b2f6-769422a5859d"}
info: <-- POST /wd/hub/session/718c98fd-4193-4956-b2f6-769422a5859d/element/4/value 500 25501.077 ms - 218 
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"UiSelector[TEXT=First Name, INSTANCE=0]","status":7}
info: --> DELETE /wd/hub/session/718c98fd-4193-4956-b2f6-769422a5859d {}
info: Shutting down appium session
info: [debug] Pressing the HOME button

it seems that it works fine on my side if using appium v1.3.4-beta1:
https://discuss.appium.io/t/appium-1-3-4-beta-released/1618/2