Appium doesn't see spinner menu in app source (Android)

I’m trying to test an Android app that has a registration form. There is a part in the form that asks you to select gender but Appium doesn’t see the elements of the spinner or the spinner itself. I tried using touchPerform but it crashed the app.

00

It looks like this in the Android Studio’s layout inspector:

35

44

  1. if you are on “UIAutomator” with Appium -> you can double check it with “uiautomatorviewer” tool from android SDK: …/Android/sdk/tools/bin.
  2. you can also check output of “driver.getPageSource()” on this screen.
  3. while tap on element makes some problem with app tap by coordinates should be 100% safe workaround instead.
  1. Thank you for introducing me to this tool. I’m new to Android testing and I will use this from now on. But unfortunately it is not listed there either.
  2. It is not listed in the page source.
  3. Tap by coordinates works great on the Appium desktop. But the app crashes when I run the test script. It says unknown error: An unknown server-side error occurred while processing the command. Original error: unknown action undefined

Here are the logs:

appium-server-logs.txt (50.9 KB)

Pls provide code how you making tap. Regarding test app crash it should be app problem. Look close to it stacktrace.

On second thought the app might not be crashing. The test ends so fast after the error I thought it crashed. Anyway here’s my code:

$("android=new UiSelector().resourceId(\"com.mecl.la3eb.beta:id/editTextInput\").text(\"Gender\")").click();
driver.pause(1000);
driver.touchAction({actions: 'tap', x: 213, y: 805});

Ok. Where did you took coordinates? While you does not see needed element - you should identify some element on screen. Get it location. And move it a bit to your element.

I solved it by using touchPerform instead of touchAction like this:

driver.touchPerform([
            { action: 'press', options: { x: 213, y: 805 }},
            { action: 'wait', options: {ms: 100}},
            { action: 'release' }
        ]);

Thank you for your time.

1 Like

@serra check examples here -> http://appium.io/docs/en/commands/interactions/touch/touch-perform/

Just to chime in here: @serra you aren’t crazy - the native drop downs are not ‘visible’ to appium for me either, I’m on 1.17.0. The uiautomator strategy doesn’t work because there isn’t anything mapped to the xml mock to identify from.
my work-around, which is still not super great and it’s frustrating to no end.

location = picker_element.element.location # get the selenium element of the android picker
size = picker_element.element.size
# OPEN PICKER
sleep(2) # the dropdown sometimes isn’t ‘open’ when it attempts to clicks.
over = location[0] + size[0]/2 # Get the center co-ords of the picker dropdown field then go down by the amount you want and over half a picker width.
down = location[1] + ((size[1]/2 + size[1]) + (picker_count*size[1]))
action = Appium::TouchAction.new
action.press(x: over, y: down).wait(100).release # This needs to be toggled a bit depending on the field.
action.perform

My app is also not released so I can’t give you examples, but I know its an android.widget.Spinner. that is being used. So it’s native android.
Obviously I’m using ruby here, but I’m sure you can get what you need from this.