Dealing with fragments

Is there a way to deal with fragments?
Appium doesn’t find any elements on fragments with findElement…

How can I test fragments with Appium?

1 Like

I would also like know, i just started using appium and seems like fragments are a huge part of certain native apps. Is this a future update or out-scope for appium.


After research of more then 6 month, there is no way to access elements on fragments.
If you want to test an Android App, change back to Robotium or Robolectric.

Ill look into those now

So is there any updates to this? i feel like appium and android without this feature is almost worthless…

You’ll have to describe your situation in much more detail. I’ve been using Appium for a very long time, and I’ve never seen fragments be an issue.

To start, you can list what version of Appium you’re using, some Appium logs (use a pastebin service. Please don’t spam the forum), and a sample of your testing code that demonstrates the issue. What is the layout structure of your application?

What does the Android SDK uiautomatorviewer tool say for your application? Ideally, you would make a post with the XML .uix file and screenshot .png file attached so everyone can take a look at your app.

Also good to know would be what Android version your test device is running. Devices running systems older than Android 4.2 have to use the Selendroid framework for testing.

In the next day or so ill be posting all the info about my issues with appium looking into android.
ill provide:

  • screen shots
  • version android
  • version appium
  • testing code
    -logs too

Thanks for reaching back out to me

So im trying to look at auto complete text on the screen but i cant seem to find where that element is located.

Appium version
Android version i think its like API level 19.
I have no testing code anymore bc it got deleted but i dont have a way of locating it which is the first step any ways.

Now that is a blind spot I completely forgot about when it came to Appium. One thing I need to try out on my own is to write a test script using Uiautomator and run it directly on the device to see how it performs against an application showing autosuggestions. My guess is that Uiautomator has trouble with autosuggestions as well, since uiautomatorviewer shows nothing for it (which means Appium will also have trouble with it).

It might be a separate window that’s being drawn on the screen. This would need more investigation.

In any case, thanks a bunch for posting the screenshot. It really gave a lot of help to what the problem was exactly. Is this app publicly available? I’ll download it and investigate a bit as well. :smiley:

Found the app:

I did a bit of research, and it seems to be a problem that occurs in Uiautomator and Espresso.


Using adb shell dumpsys window shows the following for me: window.txt (20.1 KB)

In the dump, there is the following entry: Judging by the coordinates, this is probably the window for the auto complete drop down.

I tried uiautomator to dump out the current shown windows, but it does not show anything related to the autosuggestion list. I’ll try filing a bug report in AOSP to see if it gets any attention.

EDIT: I’ve filed the bug with AOSP. If this has ever affected your work as an automation developer, please star the issue to help increase the visibility of the bug to Android system developers.

Thankyou for everything. Ill continue with my research and see if i can find anything with it.

I did a bit more searching today on this particular issue. I found other reports on AOSP’s tracker that relate to this particular case:

  2. Appium mentioned here:

It would be nice if everyone who has been affected by this issue before to star these issues.

The cause behind why this bug appears is that the popup generated from an AutoCompleteTextView is actually another “window”. When Appium queries the view hierarchy, the popup window does not have focus, so the underlying Android framework does not return data for the popup.

As a comparison, consider the typical Android dialog. I believe Android dialogs form another window on the screen (either by starting a dialog activity or a dialog fragment, or no activity nor fragment in some cases!), but dialogs are automated safely with uiautomator and Appium because the dialogs have focus.

Another good comparison is to consider the auto-correct text box that sometimes appears when you type something the Android system deems as “incorrect”. This box forms another window that steals focus, which means that if you try to search for an element without selecting one of the auto-correct suggestions, you’ll end up getting “element not found” errors.

Any updates on this? I’m unable to locate elements, or locating incorrect elements in apps that are implemented with Fragments

pretty sure you still cant


Is there any update on this issue, i am also facing problem while dealing with fragments. It sometimes locates element and sometimes does not.

Even I was facing the same issue, but I found that the file that we install via appium inspector was causing the issue for me. So if you uninstall the test app, unlock app and appium server file from the device and get the app installed from your script it will work fine.
Make sure that you use the latest version of Java client and appium server.

You need to wait a while to load Fragment. So, just use sleep() method.