Back to project page sample_testing.
The source code is released under:
Apache License
If you think the Android project sample_testing listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.elsinga.calculator; /*from w w w . j av a2 s . co m*/ import com.android.uiautomator.core.UiObject; import com.android.uiautomator.core.UiObjectNotFoundException; import com.android.uiautomator.core.UiSelector; import com.android.uiautomator.testrunner.UiAutomatorTestCase; public class MainActivityTest extends UiAutomatorTestCase { public void testDemo() throws UiObjectNotFoundException { StartsMethods start = new StartsMethods(); start.openAllAppsScreen(); start.openAppsTab(); start.swipAndOpen(); UiObject oneButton = new UiObject(new UiSelector().text("1")); oneButton.click(); UiObject plusButton = new UiObject(new UiSelector().text("+")); plusButton.click(); UiObject threeButton = new UiObject(new UiSelector().text("3")); threeButton.click(); UiObject eqButton = new UiObject(new UiSelector().text("=")); eqButton.click(); UiObject text = new UiObject(new UiSelector().className("android.widget.EditText").text("4")); assertTrue(text.exists()); } }