Java Code Examples for android.support.test.uiautomator.UiObject#clickAndWaitForNewWindow()
The following examples show how to use
android.support.test.uiautomator.UiObject#clickAndWaitForNewWindow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainEspressoTest.java From AndroidProjects with MIT License | 5 votes |
@Test public void d() throws UiObjectNotFoundException { // Initialize UiDevice instance mDevice = UiDevice.getInstance(getInstrumentation()); // Perform a short press on the HOME button mDevice.pressHome(); // Bring up the default launcher by searching for // a UI component that matches the content-description for the launcher button UiObject allAppsButton = mDevice.findObject(new UiSelector().description("Apps")); // Perform a click on the button to bring up the launcher allAppsButton.clickAndWaitForNewWindow(); }
Example 2
Source File: LoginActivityTest.java From twittererer with Apache License 2.0 | 5 votes |
@Test public void loginSuccessful() throws UiObjectNotFoundException { UiObject loginButton = device.findObject(new UiSelector().text(LOGIN_BUTTON_TEXT)); loginButton.clickAndWaitForNewWindow(TIMEOUT); // TODO: this fails to find the text on API 24+ (Android 7+) for some reason UiObject allowButton = device.findObject(new UiSelector().text("Allow")); allowButton.clickAndWaitForNewWindow(TIMEOUT); UiObject activityTitle = device.findObject(new UiSelector() .text(getInstrumentation().getTargetContext().getString(R.string.title_activity_twitter_feed))); assertThat(activityTitle, notNullValue()); }
Example 3
Source File: LoginActivityTest.java From twittererer with Apache License 2.0 | 5 votes |
@Test public void loginCancelled() throws UiObjectNotFoundException { UiObject loginButton = device.findObject(new UiSelector().text(LOGIN_BUTTON_TEXT)); loginButton.clickAndWaitForNewWindow(TIMEOUT); // TODO: this fails to find the text on API 24+ (Android 7+) for some reason UiObject allowButton = device.findObject(new UiSelector().text("Cancel")); allowButton.clickAndWaitForNewWindow(TIMEOUT); loginButton = device.findObject(new UiSelector().text(LOGIN_BUTTON_TEXT)); assertThat(loginButton, notNullValue()); }
Example 4
Source File: MyUiAutomatorTest.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
@Test public void checkSettings() throws UiObjectNotFoundException { // Simulate a short press on the HOME button. mDevice.pressHome(); // We’re now in the home screen. Next, we want to simulate // a user bringing up the All Apps screen. // If you use the uiautomatorviewer tool to capture a snapshot // of the Home screen, notice that the All Apps button’s // content-description property has the value “Apps”. We can // use this property to create a UiSelector to find the button. UiObject allAppsButton = new UiObject(new UiSelector().description("Apps")); // Simulate a click to bring up the All Apps screen. allAppsButton.clickAndWaitForNewWindow(); // In the All Apps screen, the Settings app is located in // the Apps tab. To simulate the user bringing up the Apps tab, // we create a UiSelector to find a tab with the text // label “Apps”. UiObject appsTab = new UiObject(new UiSelector().text("Apps")); // Simulate a click to enter the Apps tab. appsTab.click(); // Next, in the apps tabs, we can simulate a user swiping until // they come to the Settings app icon. Since the container view // is scrollable, we can use a UiScrollable object. UiScrollable appViews = new UiScrollable( new UiSelector().scrollable(true)); // Set the swiping mode to horizontal (the default is vertical) appViews.setAsHorizontalList(); // create a UiSelector to find the Settings app and simulate // a user click to launch the app. UiObject settingsApp = appViews .getChildByText(new UiSelector() .className(android.widget.TextView.class.getName()), "Settings"); settingsApp.clickAndWaitForNewWindow(); // Validate that the package name is the expected one UiObject settingsValidation = new UiObject( new UiSelector() .packageName("com.android.settings")); assertThat(settingsValidation.exists(), equalTo(true)); }