Skip to content
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.wordpress.android.e2e.pages;

import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;

Expand All @@ -22,6 +24,13 @@ public static void scrollToTop() {

private static RecyclerView getRecyclerView() {
ViewPager pager = getCurrentActivity().findViewById(R.id.postPager);
return (RecyclerView) pager.getChildAt(pager.getCurrentItem()).findViewById(R.id.recycler_view);
RecyclerView recyclerView = (RecyclerView) pager.getChildAt(pager.getCurrentItem())
.findViewById(R.id.recycler_view);
if (recyclerView == null) {
// Workaround for cases when recyclerview id missing
recyclerView = (RecyclerView) ((ViewGroup) ((ViewGroup) (pager.getChildAt(pager.getCurrentItem()))
.findViewById(R.id.ptr_layout)).getChildAt(0)).getChildAt(0);
}
return recyclerView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
import static androidx.test.espresso.action.ViewActions.longClick;
import static androidx.test.espresso.action.ViewActions.replaceText;
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static org.wordpress.android.support.BetterScrollToAction.scrollTo;
import static androidx.test.espresso.action.ViewActions.swipeLeft;
import static androidx.test.espresso.action.ViewActions.swipeRight;
Expand Down Expand Up @@ -111,6 +112,10 @@ public static void clickOn(ViewInteraction viewInteraction) {
idleFor(500); // allow for transitions
}

public static void clickOnViewWithContentDescription(String contentDescription) {
clickOn(onView(withContentDescription(contentDescription)));
}

/**
* Returns an action that performs a single click on the view.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.wordpress.android.util.image.ImageType;

import static org.wordpress.android.support.WPSupportUtils.clickOn;
import static org.wordpress.android.support.WPSupportUtils.clickOnViewWithContentDescription;
import static org.wordpress.android.support.WPSupportUtils.dialogExistsWithTitle;
import static org.wordpress.android.support.WPSupportUtils.getCurrentActivity;
import static org.wordpress.android.support.WPSupportUtils.getTranslatedString;
Expand Down Expand Up @@ -62,29 +63,18 @@ public void wPScreenshotTest() {

wpLogin();

idleFor(1000);
takeScreenshot("1-build-and-manage-your-website");

navigateMySite();
editBlogPost();
manageMedia();
navigateNotifications();
navigateDiscover();
navigateStats();
navigateMySite();
navigateNotifications();
manageMedia();

// Turn Demo Mode off on the emulator when we're done
mDemoModeEnabler.disable();
logoutIfNecessary();
}

private void navigateMySite() {
// Click on the "Sites" tab and take a screenshot
clickOn(R.id.nav_sites);

waitForElementToBeDisplayedWithoutFailure(R.id.row_blog_posts);

takeScreenshot("4-keep-tabs-on-your-site");
}

private void editBlogPost() {
// Choose the "sites" tab in the nav
clickOn(R.id.nav_sites);
Expand All @@ -100,24 +90,21 @@ private void editBlogPost() {
// Choose "Drafts"
selectItemWithTitleInTabLayout(getTranslatedString(R.string.post_list_tab_drafts), R.id.tabLayout);

// Get a screenshot of the writing feature (without image)
String name = "2-create-beautiful-posts-and-pages";
screenshotPostWithName("Time to Book Summer Sessions", name, false);
// TODO: Tap the + in the editor toolbar to open the block library

// Get a screenshot of the drafts feature
screenshotPostWithName("Ideas", "6-capture-ideas-on-the-go", false);
// Get a screenshot of the editor with the block library expanded
String name = "1-create-a-site-or-start-a-blog";
screenshotPostWithName("Summer Band Jam", name, false, true);

// Get a screenshot of the drafts feature
screenshotPostWithName("Summer Band Jam", "7-create-beautiful-posts-and-pages", true);

// Get a screenshot for "write without compromises"
screenshotPostWithName("Now Booking Summer Sessions", "8-write-without-compromises", true);

// Exit back to the main activity
pressBackUntilElementIsDisplayed(R.id.nav_sites);
}

private void screenshotPostWithName(String name, String screenshotName, boolean hideKeyboard) {
@SuppressWarnings("checkstyle:WhitespaceAround") private void screenshotPostWithName(String name,
String screenshotName,
boolean hideKeyboard,
boolean openBlockList) {
idleFor(2000);

PostsListPage.scrollToTop();
Expand All @@ -137,20 +124,51 @@ private void screenshotPostWithName(String name, String screenshotName, boolean
Espresso.closeSoftKeyboard();
}

if(openBlockList) {
clickOnViewWithContentDescription("Add block, Double tap to add a block");
}

takeScreenshot(screenshotName);
pressBackUntilElementIsDisplayed(R.id.tabLayout);
}

private void manageMedia() {
// Click on the "Sites" tab in the nav, then choose "Media"
private void navigateDiscover() {
// Click on the "Reader" tab and take a screenshot
clickOn(R.id.nav_reader);

// TODO: add this back after mocked data for Discover has been fixed
// waitForElementToBeDisplayedWithoutFailure(R.id.interests_fragment_container);

takeScreenshot("2-discover-new-reads");

// Exit back to the main activity
pressBackUntilElementIsDisplayed(R.id.nav_sites);
}

private void navigateStats() {
// Click on the "Sites" tab in the nav, then choose "Stats"
clickOn(R.id.nav_sites);
clickOn(R.id.quick_action_media_button);
clickOn(R.id.row_stats);

waitForElementToBeDisplayedWithoutFailure(R.id.media_grid_item_image);
// Show the months view
selectItemWithTitleInTabLayout(getTranslatedString(R.string.stats_timeframe_months), R.id.tabLayout);

// Wait for the stats to load
idleFor(5000);

takeScreenshot("5-share-from-anywhere");
takeScreenshot("3-build-an-audience");

pressBackUntilElementIsDisplayed(R.id.quick_action_media_button);
// Exit the Stats Activity
pressBackUntilElementIsDisplayed(R.id.nav_sites);
}

private void navigateMySite() {
// Click on the "Sites" tab and take a screenshot
clickOn(R.id.nav_sites);

waitForElementToBeDisplayedWithoutFailure(R.id.row_blog_posts);

takeScreenshot("4-keep-tabs-on-your-site");
}

private void navigateNotifications() {
Expand All @@ -161,27 +179,22 @@ private void navigateNotifications() {
waitForImagesOfTypeWithPlaceholder(R.id.note_avatar, ImageType.AVATAR);


takeScreenshot("4-check-whats-happening-in-real-time");
takeScreenshot("5-reply-in-real-time");

// Exit the notifications activity
pressBackUntilElementIsDisplayed(R.id.nav_sites);
}

private void navigateStats() {
// Click on the "Sites" tab in the nav, then choose "Stats"
private void manageMedia() {
// Click on the "Sites" tab in the nav, then choose "Media"
clickOn(R.id.nav_sites);
clickOn(R.id.row_stats);

// Show the year view – it'll have the best layout
selectItemWithTitleInTabLayout(getTranslatedString(R.string.stats_timeframe_years), R.id.tabLayout);
clickOn(R.id.quick_action_media_button);

// Wait for the stats to load
idleFor(5000);
waitForElementToBeDisplayedWithoutFailure(R.id.media_grid_item_image);

takeScreenshot("3-track-what-your-visitors-love");
takeScreenshot("6-upload-on-the-go");

// Exit the Stats Activity
pressBackUntilElementIsDisplayed(R.id.nav_sites);
pressBackUntilElementIsDisplayed(R.id.quick_action_media_button);
}

private void takeScreenshot(String screenshotName) {
Expand Down