Skip to content

Instantly share code, notes, and snippets.

@FisherKK
Last active September 29, 2020 22:04
Show Gist options
  • Save FisherKK/6485d9bd62544bb2af45dd4a85dbd092 to your computer and use it in GitHub Desktop.
Save FisherKK/6485d9bd62544bb2af45dd4a85dbd092 to your computer and use it in GitHub Desktop.
@Test
public void testFacebook_correctData_enterNotificationCenter() throws Exception {
final UiDevice mDevice =
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
final int timeOut = 1000 * 60;
// Login Activity
onView(withId(R.id.btnFacebookLogin)).perform(click());
// Facebook WebView - Page 1
mDevice.wait(Until.findObject(By.clazz(WebView.class)), timeOut);
// Set Login
UiObject emailInput = mDevice.findObject(new UiSelector()
.instance(0)
.className(EditText.class));
emailInput.waitForExists(timeOut);
emailInput.setText("android_wppcmrq_facebook@tfbnw.net");
// Set Password
UiObject passwordInput = mDevice.findObject(new UiSelector()
.instance(1)
.className(EditText.class));
passwordInput.waitForExists(timeOut);
passwordInput.setText("testPassword");
// Confirm Button Click
UiObject buttonLogin = mDevice.findObject(new UiSelector()
.instance(0)
.className(Button.class));
buttonLogin.waitForExists(timeOut);
buttonLogin.clickAndWaitForNewWindow();
// Facebook WebView - Page 2
UiObject buttonOk = mDevice.findObject(new UiSelector()
.instance(1)
.className(Button.class));
buttonOk.waitForExists(timeOut);
buttonOk.click();
// should be properly synchronised with Espresso via IdlingResource,
// ConditionWatcher or any similar waiting solution
Thread.sleep(15000);
// NotificationCenter Activity
assertThat(getCurrentActivity() instanceof NotificationCenterActivity, is(true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment