android-uiautomator

uiautomatorviewer - What does NAF stand for?


It's my understanding that UIAutomator is unable to automate any elements where NAF = true in uiautomatorviewer. I've searched high and low but I can't for the life of me find what NAF stands for. Does anyone know?


Solution

  • "Not Accessibility Friendly"

    These are UI elements which are apparently interactive, but which don't have accessibility affordances like content descriptions.

    From the source for AccessibilityNodeInfoDumper.java (part of uiautomator):

    /**
     * We're looking for UI controls that are enabled, clickable but have no
     * text nor content-description. Such controls configuration indicate an
     * interactive control is present in the UI and is most likely not
     * accessibility friendly. We refer to such controls here as NAF controls
     * (Not Accessibility Friendly)
     *
     * @param node
     * @return false if a node fails the check, true if all is OK
     */
    private static boolean nafCheck(AccessibilityNodeInfo node) {
        boolean isNaf = node.isClickable() && node.isEnabled()
                && safeCharSeqToString(node.getContentDescription()).isEmpty()
                && safeCharSeqToString(node.getText()).isEmpty();
        if (!isNaf)
            return true;
        // check children since sometimes the containing element is clickable
        // and NAF but a child's text or description is available. Will assume
        // such layout as fine.
        return childNafCheck(node);
    }