tools.fastlane.screengrab.Screengrab Java Examples

The following examples show how to use tools.fastlane.screengrab.Screengrab. 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: TVScreenshots.java    From firefox-echo-show with Mozilla Public License 2.0 6 votes vote down vote up
@Test
    public void unpinTileInHome() throws InterruptedException, UiObjectNotFoundException {
        /* default home-screen in the main activity should be displayed */
        mActivityTestRule.launchActivity(intent);

//        onView(allOf(withId(R.id.urlInputView), isDisplayed(), hasFocus()));

        mDevice.pressDPadDown();
        mDevice.pressMenu();

        onView(withText(R.string.homescreen_tile_remove))
                .check(matches(isDisplayed()));

        Screengrab.screenshot("menu-remove-tile");

        mDevice.pressBack();
    }
 
Example #2
Source File: BrowserScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 6 votes vote down vote up
private void takeScreenshotOfFindDialog() throws Exception {
    UiObject findinpageMenuItem = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/find_in_page")
            .enabled(true));
    UiObject findinpageCloseBtn = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/close_find_in_page")
            .enabled(true));

    TestHelper.menuButton.perform(click());
    findinpageMenuItem.waitForExists(waitingTime);
    findinpageMenuItem.click();

    findinpageCloseBtn.waitForExists(waitingTime);
    Screengrab.screenshot("Find_In_Page_Dialog");
    findinpageCloseBtn.click();
}
 
Example #3
Source File: NotificationScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void takeScreenshotOfNotification() throws Exception {
    onView(withId(R.id.urlView))
            .check(matches(isDisplayed()))
            .check(matches(hasFocus()))
            .perform(click(), replaceText(webServer.url("/").toString()), pressImeActionButton());

    onView(withId(R.id.display_url))
            .check(matches(isDisplayed()))
            .check(matches(withText(containsString(webServer.getHostName()))));

    final UiObject openAction = device.findObject(new UiSelector()
            .descriptionContains(getString(R.string.notification_action_open))
            .resourceId("android:id/action0")
            .enabled(true));

    device.openNotification();

    try {
        if (!openAction.waitForExists(waitingTime)) {
            // The notification is not expanded. Let's expand it now.
            device.findObject(new UiSelector()
                    .text(getString(R.string.app_name)))
                    .swipeDown(20);

            assertTrue(openAction.waitForExists(waitingTime));
        }

        Screengrab.screenshot("DeleteHistory_NotificationBar");
    } finally {
        // Close notification tray again
        device.pressBack();
    }
}
 
Example #4
Source File: HomeScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void takeScreenshotOfHomeScreen() {
    onView(withId(R.id.urlView))
            .check(matches(isDisplayed()))
            .check(matches(hasFocus()));
    SystemClock.sleep(5000);
    Screengrab.screenshot("Home_View");
}
 
Example #5
Source File: ErrorPagesScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void takeScreenshotsOfErrorPages() {
    for (ErrorTypes error: ErrorTypes.values()) {
        onView(withId(R.id.urlView))
                .check(matches(isDisplayed()))
                .check(matches(hasFocus()))
                .perform(click(), replaceText("error:" + error.value), pressImeActionButton());

        assertTrue(TestHelper.webView.waitForExists(waitingTime));
        assertTrue(TestHelper.progressBar.waitUntilGone(waitingTime));

        // Android O has an issue with using Locator.ID
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            UiObject tryAgainBtn = device.findObject(new UiSelector()
                    .resourceId("errorTryAgain")
                    .clickable(true));
            assertTrue(tryAgainBtn.waitForExists(waitingTime));
        } else {
            onWebView()
                    .withElement(findElement(Locator.ID, "errorTitle"))
                    .perform(webClick());

            onWebView()
                    .withElement(findElement(Locator.ID, "errorTryAgain"))
                    .perform(webScrollIntoView());
        }

        Screengrab.screenshot(error.name());

        onView(withId(R.id.display_url))
                .check(matches(isDisplayed()))
                .perform(click());
    }
}
 
Example #6
Source File: FirstRunScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void takeScreenshotsOfFirstrun() throws UiObjectNotFoundException {
    onView(withText(R.string.firstrun_defaultbrowser_title))
            .check(matches(isDisplayed()));

    device.waitForIdle();
    SystemClock.sleep(5000);

    Screengrab.screenshot("Onboarding_1_View");
    TestHelper.nextBtn.click();

    assertTrue(device.findObject(new UiSelector()
            .text(getString(R.string.firstrun_search_title))
            .enabled(true)
    ).waitForExists(waitingTime));

    Screengrab.screenshot("Onboarding_2_View");
    TestHelper.nextBtn.click();

    assertTrue(device.findObject(new UiSelector()
            .text(getString(R.string.firstrun_shortcut_title))
            .enabled(true)
    ).waitForExists(waitingTime));

    Screengrab.screenshot("Onboarding_3_View");
    TestHelper.nextBtn.click();

    assertTrue(device.findObject(new UiSelector()
            .text(getString(R.string.firstrun_privacy_title))
            .enabled(true)
    ).waitForExists(waitingTime));

    Screengrab.screenshot("Onboarding_last_View");
}
 
Example #7
Source File: ScreenshotTest.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Before
public void setUpScreenshots() {
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    targetContext = instrumentation.getTargetContext();
    device = UiDevice.getInstance(instrumentation);

    // Use this to switch between default strategy and HostScreencap strategy
    Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
    //Screengrab.setDefaultScreenshotStrategy(new HostScreencapScreenshotStrategy(device));

    device.waitForIdle();
}
 
Example #8
Source File: HomeScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void takeScreenshotOfMenu() {
    TestHelper.menuButton.perform(click());

    onView(withText(R.string.menu_whats_new))
            .check(matches(isDisplayed()));

    Screengrab.screenshot("MainViewMenu");
}
 
Example #9
Source File: BrowserScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
private void takeScreenshotofSecureCon() throws Exception {

        // take the security info of google.com for https connection
        onView(withId(R.id.urlView))
                .check(matches(isDisplayed()))
                .check(matches(hasFocus()))
                .perform(click(), replaceText("www.google.com"), pressImeActionButton());
        TestHelper.waitForWebContent();
        TestHelper.progressBar.waitUntilGone(waitingTime);
        TestHelper.securityInfoIcon.click();
        TestHelper.identityState.waitForExists(waitingTime);
        Screengrab.screenshot("secure_connection");
        device.pressBack();
    }
 
Example #10
Source File: BrowserScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
private void takeScreenshotofInsecureCon() throws Exception {

        TestHelper.securityInfoIcon.click();
        TestHelper.identityState.waitForExists(waitingTime);
        Screengrab.screenshot("insecure_connection");
        device.pressBack();
    }
 
Example #11
Source File: HomeScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void takeScreenshotOfTips() {
    for (TipTypes tip: TipTypes.values()) {
        onView(withId(R.id.urlView))
                .check(matches(isDisplayed()))
                .check(matches(hasFocus()))
                .perform(click(), replaceText("l10n:tip:" + tip.value), pressImeActionButton());

        onView(withId(R.id.homeViewTipsLabel))
                .check(matches(isDisplayed()));
        Screengrab.screenshot("MainViewTip_" + tip.name());
    }
}
 
Example #12
Source File: BrowserScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
private void takeAddToHomeScreenScreenshot() throws UiObjectNotFoundException {
    TestHelper.menuButton.perform(click());

    TestHelper.AddtoHSmenuItem.waitForExists(waitingTime);
    TestHelper.AddtoHSmenuItem.click();

    TestHelper.AddtoHSCancelBtn.waitForExists(waitingTime);
    Screengrab.screenshot("AddtoHSDialog");
    TestHelper.AddtoHSCancelBtn.click();
}
 
Example #13
Source File: BrowserScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
private void takeScreenshotsOfOpenWithAndShare() throws Exception {
    /* Open_With View */
    TestHelper.menuButton.perform(click());

    UiObject openWithBtn = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/open_select_browser")
            .enabled(true));
    assertTrue(openWithBtn.waitForExists(waitingTime));
    openWithBtn.click();
    UiObject shareList = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/apps")
            .enabled(true));
    assertTrue(shareList.waitForExists(waitingTime));
    Screengrab.screenshot("OpenWith_Dialog");

    /* Share View */
    UiObject shareBtn = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/share")
            .enabled(true));
    device.pressBack();
    TestHelper.menuButton.perform(click());
    assertTrue(shareBtn.waitForExists(waitingTime));
    shareBtn.click();
    TestHelper.shareAppList.waitForExists(waitingTime);
    Screengrab.screenshot("Share_Dialog");

    device.pressBack();
}
 
Example #14
Source File: ScreenshotsTest.java    From Emoji with Apache License 2.0 5 votes vote down vote up
private void start(final Variant variant) throws InterruptedException {
  final String name = variant.name().toLowerCase(US);

  // Select the right variant.
  onView(withId(R.id.menuMainSearchOption)).perform(click());
  onView(withText(variant.title)).perform(click());

  // First text.
  onView(withId(R.id.main_activity_emoji)).perform(click());

  final int[] firstEmojis = new int[] { 0x1f913, 0x1F60E, 0x1F921, 0x1F920, 0x1F60F, 0x1F3BE };
  onView(withId(R.id.main_activity_chat_bottom_message_edittext)).perform(append("Hello what's up? " + new String(firstEmojis, 0, firstEmojis.length)));

  Thread.sleep(500); // Espresso does not synchronize it right away.
  Screengrab.screenshot(name + "_1");

  onView(withId(R.id.main_activity_send)).perform(click());

  // Second text.
  final int[] beerEmojis = new int[] { 0x1F37A, 0x1F37A, 0x1F37A };
  onView(withId(R.id.main_activity_chat_bottom_message_edittext)).perform(append(new String(beerEmojis, 0, beerEmojis.length)));
  onView(withId(R.id.main_activity_send)).perform(click());

  final int[] clinkingBeerEmoji = new int[] { 0x1F37B };
  onView(withId(R.id.main_activity_chat_bottom_message_edittext)).perform(append(new String(clinkingBeerEmoji, 0, clinkingBeerEmoji.length)));
  onView(withId(R.id.main_activity_send)).perform(click());

  Thread.sleep(500); // Espresso does not synchronize it right away.
  Screengrab.screenshot(name + "_2");

  // Third text.
  onView(withId(R.id.main_activity_send)).perform(click());

  final int[] secondEmojis = new int[] { 0x1F98B, 0x1F41E, 0x1F41D, 0x1F422, 0x1F432, 0x1F683, 0x1F37B, 0x1F943 };
  onView(withId(R.id.main_activity_chat_bottom_message_edittext)).perform(append("I don't know " + new String(secondEmojis, 0, secondEmojis.length)));

  Thread.sleep(500); // Espresso does not synchronize it right away.
  Screengrab.screenshot(name + "_3");
}
 
Example #15
Source File: ScreenshotTest.java    From firefox-echo-show with Mozilla Public License 2.0 5 votes vote down vote up
@Before
public void setUpScreenshots() {
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    targetContext = instrumentation.getTargetContext();
    device = UiDevice.getInstance(instrumentation);

    // Use this to switch between default strategy and HostScreencap strategy
    Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
    //Screengrab.setDefaultScreenshotStrategy(new HostScreencapScreenshotStrategy(device));

    device.waitForIdle();
}
 
Example #16
Source File: TVScreenshots.java    From firefox-echo-show with Mozilla Public License 2.0 5 votes vote down vote up
@Test
    public void unpinTileFromOverlay() throws InterruptedException, UiObjectNotFoundException {
    /* default home-screen in the main activity should be displayed */
        mActivityTestRule.launchActivity(intent);

//        onView(allOf(withId(R.id.urlInputView), isDisplayed(), hasFocus()))
//                .perform(typeTextIntoFocusedView("example.com"))
//                .perform(pressImeActionButton());

        onView(withId(R.id.webview))
                .check(matches(isDisplayed()));

        mDevice.pressMenu();

//        onView(withId(R.id.pinButton))
//                .check(matches(isDisplayed()))
//                .perform(click());

        onView(withText(R.string.notification_unpinned_site))
                .inRoot(withDecorView(not(is(mActivityTestRule.getActivity().getWindow().getDecorView()))))
                .check(matches(isDisplayed()));

        Screengrab.screenshot("overlay-unpinned-tile");

        mDevice.pressBack();
        mDevice.pressBack();
    }
 
Example #17
Source File: TVScreenshots.java    From firefox-echo-show with Mozilla Public License 2.0 5 votes vote down vote up
@Test
    public void pinTileFromOverlay() throws InterruptedException, UiObjectNotFoundException {
        /* default home-screen in the main activity should be displayed */
        mActivityTestRule.launchActivity(intent);

//        onView(allOf(withId(R.id.urlInputView), isDisplayed(), hasFocus()))
//                .perform(typeTextIntoFocusedView("example.com"))
//                .perform(pressImeActionButton());

        onView(withId(R.id.webview))
                .check(matches(isDisplayed()));

        mDevice.pressMenu();

//        onView(withId(R.id.pinButton))
//                .check(matches(isDisplayed()))
//                .perform(click());

        onView(withText(R.string.notification_pinned_site))
                .inRoot(withDecorView(not(is(mActivityTestRule.getActivity().getWindow().getDecorView()))))
                .check(matches(isDisplayed()));

        Screengrab.screenshot("overlay-pinned-tile");

        mDevice.pressBack();
        mDevice.pressBack();
    }
 
Example #18
Source File: BaseScreenshotTest.java    From hash-checker with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    Screengrab.setDefaultScreenshotStrategy(
            new FalconScreenshotStrategy(
                    activityTestRule.getActivity()
            )
    );
}
 
Example #19
Source File: TVScreenshots.java    From firefox-echo-show with Mozilla Public License 2.0 5 votes vote down vote up
@Test
    public void defaultHomeScreen() throws InterruptedException, UiObjectNotFoundException {
        /* capture a screenshot of the default home-screen */
        mActivityTestRule.launchActivity(intent);

//        onView(withId(R.id.urlInputView))
//                .check(matches(isDisplayed()));
//        onView(withId(R.id.homeUrlBar))
//                .check(matches(isDisplayed()));

        Screengrab.screenshot("home-screen");
    }
 
Example #20
Source File: TVScreenshots.java    From firefox-echo-show with Mozilla Public License 2.0 5 votes vote down vote up
@Test
    public void firstLaunchScreen() throws InterruptedException, UiObjectNotFoundException {
        mActivityTestRule.launchActivity(intent);

//        onView(withId(R.id.enable_turbo_mode))
//                .check(matches(isDisplayed()));
//        onView(withId(R.id.turbo_mode_title))
//                .check(matches(isDisplayed()));
//        onView(withId(R.id.disable_turbo_mode))
//                .check(matches(isDisplayed()));

        Screengrab.screenshot("first-launch");
    }
 
Example #21
Source File: BaseScreenshotTest.java    From hash-checker with Apache License 2.0 5 votes vote down vote up
public void makeScreenshot(
        @NonNull String screenshotName
) {
    Screengrab.screenshot(
            screenshotName
    );
}
 
Example #22
Source File: JUnit4StyleTests.java    From itracing2 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testTakeScreenShot()
{
    Screengrab.screenshot("hello");
}
 
Example #23
Source File: ScreenshotTest.java    From Anecdote with Apache License 2.0 4 votes vote down vote up
@Test
    public void websiteChooserScreenshots() throws InterruptedException {
        Screengrab.screenshot("websiteChooserFragment1");

        //progress dialog is now shown
        Thread.sleep(1500);

        onView(withId(R.id.recyclerView)).perform(
                RecyclerViewActions.actionOnItemAtPosition(
                        0, AnecdoteRecyclerViewAction.clickChildViewWithId(R.id.checkBox)));
        onView(withId(R.id.recyclerView)).perform(
                RecyclerViewActions.actionOnItemAtPosition(
                        1, AnecdoteRecyclerViewAction.clickChildViewWithId(R.id.checkBox)));
        onView(withId(R.id.recyclerView)).perform(
                RecyclerViewActions.actionOnItemAtPosition(
                        2, AnecdoteRecyclerViewAction.clickChildViewWithId(R.id.checkBox)));
        onView(withId(R.id.recyclerView)).perform(
                RecyclerViewActions.actionOnItemAtPosition(
                        4, AnecdoteRecyclerViewAction.clickChildViewWithId(R.id.checkBox)));

        Thread.sleep(300);

        Screengrab.screenshot("websiteChooserFragment2");

        onView(withId(R.id.saveButton)).perform(click());
        Thread.sleep(2000);

        Screengrab.screenshot("anecdote1");


//        onView(allOf(withId(R.id.recyclerView), withClassName(endsWith("TextView")))).perform(
//                RecyclerViewActions.actionOnItemAtPosition(
//                        0,  AnecdoteRecyclerViewAction.clickAnecdoteTextViewWithId(R.id.contentTextView)));

        onView(allOf(withId(R.id.recyclerView))).perform(
                RecyclerViewActions.actionOnItemAtPosition(
                        0,  AnecdoteRecyclerViewAction.clickAnecdoteTextViewWithId(R.id.contentTextView)));

        Thread.sleep(500);

        Screengrab.screenshot("anecdoteCliked");

        // Dump check
        Assert.assertEquals(1, 1);
    }
 
Example #24
Source File: JUnit4StyleTests.java    From itracing2 with GNU General Public License v2.0 4 votes vote down vote up
@BeforeClass
public static void beforeAll()
{
    Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
}
 
Example #25
Source File: AllowListScreenshots.java    From focus-android with Mozilla Public License 2.0 4 votes vote down vote up
@Test
public void takeScreenshotsOfMenuandAllowlist() throws UiObjectNotFoundException {
    SystemClock.sleep(5000);
    onView(withId(R.id.urlView))
            .check(matches(isDisplayed()))
            .check(matches(hasFocus()))
            .perform(click(), replaceText(webServer.url("/").toString()));

    onView(withId(R.id.urlView))
            .check(matches(isDisplayed()))
            .check(matches(hasFocus()))
            .perform(pressImeActionButton());

    device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/webview")
            .enabled(true))
            .waitForExists(waitingTime);

    TestHelper.menuButton.perform(click());
    Screengrab.screenshot("BrowserViewMenu");
    onView(withId(R.id.blocking_switch)).perform(click());

    // Open setting
    onView(withId(R.id.menuView))
            .check(matches(isDisplayed()))
            .perform(click());
    onView(withId(R.id.settings))
            .check(matches(isDisplayed()))
            .perform(click());
    onView(withText(R.string.preference_privacy_and_security_header)).perform(click());

    UiScrollable settingsView = new UiScrollable(new UiSelector().scrollable(true));
    if (settingsView.exists()) {        // On tablet, this will not be found
        settingsView.scrollToEnd(5);
        onView(withText(R.string.preference_exceptions)).perform(click());
    }

    onView(withId(R.id.removeAllExceptions))
            .check(matches(isDisplayed()));
    Screengrab.screenshot("ExceptionsDialog");
    onView(withId(R.id.removeAllExceptions))
            .perform(click());

}
 
Example #26
Source File: ScreenshotTest.java    From focus-android with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected void failed(Throwable e, Description description) {
    // On error take a screenshot so that we can debug it easily
    Screengrab.screenshot("FAILURE-" + getScreenshotName(description));
}
 
Example #27
Source File: BrowserScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 4 votes vote down vote up
private void takeScreenshotOfTabsTrayAndErase() throws Exception {
    final UiObject mozillaImage = device.findObject(new UiSelector()
            .resourceId("download")
            .enabled(true));

    UiObject imageMenuTitle = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/topPanel")
            .enabled(true));
    UiObject openNewTabTitle = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/design_menu_item_text")
            .text(getString(R.string.contextmenu_open_in_new_tab))
            .enabled(true));
    UiObject multiTabBtn = device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/tabs")
            .enabled(true));
    UiObject eraseHistoryBtn = device.findObject(new UiSelector()
            .text(getString(R.string.tabs_tray_action_erase))
            .enabled(true));

    assertTrue(mozillaImage.waitForExists(waitingTime));
    mozillaImage.dragTo(mozillaImage, 7);
    assertTrue(imageMenuTitle.waitForExists(waitingTime));
    assertTrue(imageMenuTitle.exists());
    Screengrab.screenshot("Image_Context_Menu");

    //Open a new tab
    openNewTabTitle.click();
    TestHelper.mDevice.wait(Until.findObject(
            By.res(TestHelper.getAppName(), "snackbar_text")), 5000);
    Screengrab.screenshot("New_Tab_Popup");
    TestHelper.mDevice.wait(Until.gone(
            By.res(TestHelper.getAppName(), "snackbar_text")), 5000);

    assertTrue(multiTabBtn.waitForExists(waitingTime));
    multiTabBtn.click();
    assertTrue(eraseHistoryBtn.waitForExists(waitingTime));
    Screengrab.screenshot("Multi_Tab_Menu");

    eraseHistoryBtn.click();

    device.wait(Until.findObject(
            By.res(TestHelper.getAppName(), "snackbar_text")), waitingTime);

    Screengrab.screenshot("YourBrowsingHistoryHasBeenErased");
}
 
Example #28
Source File: BrowserScreenScreenshots.java    From focus-android with Mozilla Public License 2.0 4 votes vote down vote up
private void takeScreenshotsOfBrowsingView() {
    onView(withId(R.id.urlView))
            .check(matches(isDisplayed()));

    // click yes, then go into search dialog and change to twitter, or create twitter engine
    // If it does not exist (In order to get search unavailable dialog)
    openSettings();
    onView(withText(R.string.preference_category_search))
            .perform(click());
    onView(allOf(withText(R.string.preference_search_engine_label),
            withResourceName("title")))
            .perform(click());
    onView(withText(R.string.preference_search_installed_search_engines))
            .check(matches(isDisplayed()));

   try {
       onView(withText("Twitter"))
               .check(matches(isDisplayed()))
               .perform(click());
   } catch (NoMatchingViewException doesnotexist) {
       final String addEngineLabel = getString(R.string.preference_search_add2);
       onView(withText(addEngineLabel))
               .check(matches(isEnabled()))
               .perform(click());
       onView(withId(R.id.edit_engine_name))
               .check(matches(isEnabled()));
       onView(withId(R.id.edit_engine_name))
               .perform(replaceText("twitter"));
       onView(withId(R.id.edit_search_string))
               .perform(replaceText("https://twitter.com/search?q=%s"));
       onView(withId(R.id.menu_save_search_engine))
               .check(matches(isEnabled()))
               .perform(click());
   }

    device.pressBack();
    onView(allOf(withText(R.string.preference_search_engine_label),
            withResourceName("title")))
            .check(matches(isDisplayed()));
    device.pressBack();
    onView(withText(R.string.preference_category_search))
            .check(matches(isDisplayed()));
    device.pressBack();

    onView(withId(R.id.urlView))
            .check(matches(isDisplayed()))
            .check(matches(hasFocus()))
            .perform(click(), replaceText(webServer.url("/").toString()));
    try {
        onView(withId(R.id.enable_search_suggestions_button))
                .check(matches(isDisplayed()));
        Screengrab.screenshot("Enable_Suggestion_dialog");
        onView(withId(R.id.enable_search_suggestions_button))
                .perform(click());
        Screengrab.screenshot("Suggestion_unavailable_dialog");
        onView(withId(R.id.dismiss_no_suggestions_message))
                .perform(click());
    } catch (AssertionError dne) { }

    onView(withId(R.id.urlView))
            .check(matches(isDisplayed()))
            .check(matches(hasFocus()))
            .perform(pressImeActionButton());

    device.findObject(new UiSelector()
            .resourceId(TestHelper.getAppName() + ":id/webview")
            .enabled(true))
            .waitForExists(waitingTime);

    onView(withId(R.id.display_url))
            .check(matches(isDisplayed()))
            .check(matches(withText(containsString(webServer.getHostName()))));

    // Check add link to autocomplete text
    onView(withId(R.id.display_url)).perform(click());
    onView(withId(R.id.addToAutoComplete))
            .check(matches(isDisplayed()));
    Screengrab.screenshot("Addlink_autocomplete");
    onView(withId(R.id.addToAutoComplete))
            .perform(click());
    Screengrab.screenshot("new_customURL_popup");
    onView(withId(R.id.display_url)).perform(click());
    onView(withId(R.id.addToAutoComplete))
            .perform(click());
    Screengrab.screenshot("customURL_alreadyexists_popup");
}
 
Example #29
Source File: ScreenshotsTest.java    From Emoji with Apache License 2.0 4 votes vote down vote up
@Before public void setUp() {
  Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
}
 
Example #30
Source File: ScreenshotTest.java    From firefox-echo-show with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected void failed(Throwable e, Description description) {
    // On error take a screenshot so that we can debug it easily
    Screengrab.screenshot("FAILURE-" + getScreenshotName(description));
}