What is the best approach to test android home screen widget ? Its very difficult to find any example code :/ What frameworks support that tests ?
try UIAutomator use android-sdk/tools/uiautomatorviewer to get widget properties
    import android.test.InstrumentationTestCase;
    import android.support.test.uiautomator.UiDevice;
    import android.support.test.uiautomator.By;
    public class CalculatorUiTest extends InstrumentationTestCase {
        private UiDevice mDevice;
        public void setUp() {
            // Initialize UiDevice instance
            mDevice = UiDevice.getInstance(getInstrumentation());
            // Start from the home screen
            mDevice.pressHome();
            UiObject widgetButton = mDevice.findObject(new UiSelector()
            .text("OK"))
            .className("android.widget.Button"));
            widgetButton.clickAndWaitForNewWindow();
        }
}
Android Testing Support Library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With