/* * Copyright (C) 2013 DroidDriver committers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.android.droiddriver; import android.graphics.Rect; import com.google.android.droiddriver.actions.Action; import com.google.android.droiddriver.actions.InputInjector; import com.google.android.droiddriver.finders.Attribute; import com.google.android.droiddriver.finders.Predicate; import com.google.android.droiddriver.instrumentation.InstrumentationDriver; import com.google.android.droiddriver.scroll.Direction.PhysicalDirection; import com.google.android.droiddriver.uiautomation.UiAutomationDriver; import java.util.List; /** * Represents an UI element within an Android App. *
* UI elements are generally views. Users can get attributes and perform
* actions. Note that actions often update UiElement, so users are advised not
* to store instances for later use -- the instances could become stale.
*/
public interface UiElement {
/**
* Gets the text of this element.
*/
String getText();
/**
* Gets the content description of this element.
*/
String getContentDescription();
/**
* Gets the class name of the underlying view. The actual name could be
* overridden.
*
* @see com.google.android.droiddriver.instrumentation.ViewElement#overrideClassName
*/
String getClassName();
/**
* Gets the resource id of this element.
*/
String getResourceId();
/**
* Gets the package name of this element.
*/
String getPackageName();
/**
* @return whether or not this element is visible on the device's display.
*/
boolean isVisible();
/**
* @return whether this element is checkable.
*/
boolean isCheckable();
/**
* @return whether this element is checked.
*/
boolean isChecked();
/**
* @return whether this element is clickable.
*/
boolean isClickable();
/**
* @return whether this element is enabled.
*/
boolean isEnabled();
/**
* @return whether this element is focusable.
*/
boolean isFocusable();
/**
* @return whether this element is focused.
*/
boolean isFocused();
/**
* @return whether this element is scrollable.
*/
boolean isScrollable();
/**
* @return whether this element is long-clickable.
*/
boolean isLongClickable();
/**
* @return whether this element is password.
*/
boolean isPassword();
/**
* @return whether this element is selected.
*/
boolean isSelected();
/**
* Gets the UiElement bounds in screen coordinates. The coordinates may not be
* visible on screen.
*/
Rect getBounds();
/**
* Gets the UiElement bounds in screen coordinates. The coordinates will be
* visible on screen.
*/
Rect getVisibleBounds();
/**
* @return value of the given attribute.
*/
* Another discrepancy between {@link InstrumentationDriver}
* {@link UiAutomationDriver} is the order of children. The Accessibility API
* returns children in the order of layout (see
* {@link android.view.ViewGroup#addChildrenForAccessibility}, which is added
* in API16).
*
*
*