Skip to content

Instantly share code, notes, and snippets.

@iltempo
Created May 20, 2019 12:07
Show Gist options
  • Save iltempo/105be219ab38e6ce4c54c47aa00fbaba to your computer and use it in GitHub Desktop.
Save iltempo/105be219ab38e6ce4c54c47aa00fbaba to your computer and use it in GitHub Desktop.
public class TestMessages extends ActivityTest {
@Test
public void writeMessageToContact() throws Exception{
onView(withId(userFieldId)).perform(typeText("test_user@domain.com"), closeSoftKeyboard());
onView(withId(is(passwordFieldId))).perform(scrollTo()).check(matches(isDisplayed())).perform(typeText("mySecretPassword"), closeSoftKeyboard());
onView(withId(is(loginButtonId))).perform(scrollTo(), click());
openDrawerAndGoToSection(DrawerItem.MESSAGES);
onView(withId(R.id.floating_action_button)).check(matches(isDisplayed())).perform(click());
onView(withId(com.xing.android.R.id.contact_chooser)).perform(click(), typeText("John Doe"));
Thread.sleep(TIMEOUT2);
onView(withId(com.xing.android.R.id.editmessage_subject)).perform(typeText("This is the subject"), closeSoftKeyboard());
Thread.sleep(TIMEOUT2);
onView(withId(R.id.editmessage_body)).perform(typeText("This is the message body"), closeSoftKeyboard());
Thread.sleep(500);
onView(withId(R.id.menu_send)).perform(click());
Thread.sleep(10000);
onView(withText(messageSubject)).check(matches(isDisplayed()));
logoutUser();
onView(withId(userFieldId)).perform(typeText("john_doe@domain.com"), closeSoftKeyboard());
onView(withId(is(passwordFieldId))).perform(scrollTo()).check(matches(isDisplayed())).perform(typeText("my2SecretPassword"), closeSoftKeyboard());
onView(withId(is(loginButtonId))).perform(scrollTo(), click());
openDrawerAndGoToSection(DrawerItem.MESSAGES);
onView(withText("This is the subject")).check(matches(isDisplayed()));
onView(withText("This is the subject")).perform(click());
onView(allOf(withId(R.id.comment_bar_edittext), isDisplayed())).perform(typeText("This is the reply"));
onView(allOf(withId(com.xing.android.R.id.comment_bar_send_action), isDisplayed())).perform(click());
logoutUser();
onView(withId(userFieldId)).perform(typeText("test_user@domain.com"), closeSoftKeyboard());
onView(withId(is(passwordFieldId))).perform(scrollTo()).check(matches(isDisplayed())).perform(typeText("mySecretPassword"), closeSoftKeyboard());
onView(withId(is(loginButtonId))).perform(scrollTo(), click());
openDrawerAndGoToSection(DrawerItem.MESSAGES);
onView(withText("This is the subject")).perform(click());
onView(withText("This is the reply")).check(matches(isDisplayed()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment