Example #1
0
  // TOCT01
  @Test(groups = {"MercuryTOCTest_001", "MercuryTOCTests", "Mercury"})
  public void MercuryTOCTest_001_TOCPresence_ListRedirection() {
    TableOfContentPageObject toc = new TableOfContentPageObject(driver);
    toc.openMercuryArticleByName(wikiURL, MercurySubpages.TOC);

    Assertion.assertTrue(toc.isTOCDisplayed(), "TOC isn't displayed");

    PageObjectLogging.log("TOC", "is displayed", true);

    boolean result = toc.isTOCUnderArticleName();
    PageObjectLogging.log(
        "TOC position", "is under article name", "is not under article name", result);

    Assertion.assertFalse(toc.isTOCMenuVisible(), "TOC menu is expanded");

    PageObjectLogging.log("TOC menu", "is collapsed", true);

    toc.clickOnTOC();

    Assertion.assertTrue(toc.isTOCMenuVisible(), "TOC menu is collapsed");

    PageObjectLogging.log("TOC menu", "is expanded", true);

    toc.clickOnTOCListElement(1);

    result = toc.isUserMovedToRightSection(1);
    PageObjectLogging.log("TOC redirection", "works", "does not work", result);

    result = toc.isH2PaddingTopMoreThan(1, H2_PADDING_TOP);
    PageObjectLogging.log("Header padding", "is correct", "is wrong", result);
  }
  public PortableInfoboxObject clickExternalLink(int index) {
    Assertion.assertFalse(externalLinks.isEmpty());
    wait.forElementVisible(externalLinks.get(index));

    externalLinks.get(index).click();
    return this;
  }
  @InBrowser(emulator = Emulator.GOOGLE_NEXUS_5)
  @Test(groups = "mercury_search_searchResultsPageHasNoSearchIconInTopBar")
  public void mercury_search_searchResultsPageHasNoSearchIconInTopBar() {
    SearchResultsPage resultsPage = new SearchResultsPage().openForQuery(SEARCH_PHRASE);

    Assertion.assertFalse(resultsPage.getTopBar().isSearchIconClickable());
  }
  @InBrowser(emulator = Emulator.GOOGLE_NEXUS_5)
  @Test(groups = "mercury_search_noSuggestionsOnSearchResultsPage")
  public void mercury_search_noSuggestionsOnSearchResultsPage() {
    SearchResultsPage searchResults =
        new SearchResultsPage().openForQuery(SEARCH_PHRASE_NO_RESULTS);

    Assertion.assertFalse(searchResults.getSearch().areSearchSuggestionsDisplayed());
  }
  @InBrowser(emulator = Emulator.GOOGLE_NEXUS_5)
  @Test(groups = "mercury_search_loadMoreResultsOnSearchResultsPageNotVisible")
  public void mercury_search_emptySearchPhrase() {
    SearchResultsPage resultsPage = new SearchResultsPage().openForQuery(EMPTY_SEARCH_PHRASE);

    Assertion.assertEquals(resultsPage.getResultCardsNumber(), 0);
    Assertion.assertFalse(resultsPage.isLoadMoreButtonVisible());
  }
  @InBrowser(emulator = Emulator.GOOGLE_NEXUS_5)
  @Test(groups = "mercury_search_searchInputDoesNotCoverNavigation")
  public void mercury_search_searchInputDoesNotCoverNavigation() {
    SearchResultsPage resultsPage = new SearchResultsPage().openForQuery(SEARCH_PHRASE);

    resultsPage.getTopBar().openNavigation();

    Assertion.assertFalse(resultsPage.getSearch().isSearchInputFieldEditable());
  }
  @InBrowser(emulator = Emulator.GOOGLE_NEXUS_5)
  @Test(groups = "mercury_search_searchNoResultsPageDisplayed")
  public void mercury_search_searchNoResultsPageDisplayed() {
    SearchResultsPage searchResults =
        new SearchResultsPage().openForQuery(SEARCH_PHRASE_NO_RESULTS);

    Assertion.assertTrue(searchResults.isNoResultsPagePresent());
    Assertion.assertFalse(searchResults.isLoadMoreButtonVisible());
  }
  @InBrowser(emulator = Emulator.GOOGLE_NEXUS_5)
  @Test(groups = "mercury_search_loadMoreResultsOnSearchResultsPageNotVisible")
  public void mercury_search_loadMoreResultsOnSearchResultsPageNotVisible() {
    SearchResultsPage resultsPage =
        new SearchResultsPage().openForQuery(SINGLE_RESULT_SEARCH_PHRASE);

    Assertion.assertTrue(resultsPage.getResultCardsNumber() < SEARCH_RESULTS_DEFAULT_NUMBER);
    Assertion.assertFalse(resultsPage.isLoadMoreButtonVisible());
  }
  // MT04
  @Test(groups = {"MercuryLightboxTest_004", "MercuryLightboxTests", "Mercury"})
  public void MercuryLightboxTest_004_UIShow_UIHide() {
    LightboxComponentObject lightbox = new LightboxComponentObject(driver);
    lightbox.openMercuryArticleByName(wikiURL, MercurySubpages.GALLERY);
    PerformTouchAction touchAction = new PerformTouchAction(driver);

    lightbox.clickGalleryImage(0);

    Assertion.assertTrue(lightbox.isLightboxHeaderDisplayed(), "Lightbox header isn't displayed");

    Assertion.assertTrue(lightbox.isLightboxFooterDisplayed(), "Lightbox footer isn't displayed");

    touchAction.tapOnPointXY(50, 50, 500, 5000);

    Assertion.assertFalse(lightbox.isLightboxHeaderDisplayed(), "Lightbox header is displayed");

    Assertion.assertFalse(lightbox.isLightboxFooterDisplayed(), "Lightbox footer is displayed");

    touchAction.tapOnPointXY(50, 50, 500, 5000);

    Assertion.assertTrue(lightbox.isLightboxHeaderDisplayed(), "Lightbox header isn't displayed");

    Assertion.assertTrue(lightbox.isLightboxFooterDisplayed(), "Lightbox footer isn't displayed");
  }
  @InBrowser(emulator = Emulator.GOOGLE_NEXUS_5)
  @Test(groups = "mercury_search_redirectToNewResultsPageFromNoResults")
  public void mercury_search_redirectToNewResultsPageFromNoResults() {
    SearchResultsPage searchResults =
        new SearchResultsPage()
            .openForQuery(SEARCH_PHRASE_NO_RESULTS)
            .clickTryAnotherSearch()
            .getSearch()
            .typeInSearch(SEARCH_PHRASE)
            .clickEnterAndNavigateToSearchResults();

    Assertion.assertTrue(searchResults.isSearchResultsPageOpen());
    Assertion.assertFalse(searchResults.isNoResultsPagePresent());
    Assertion.assertTrue(searchResults.areResultsPresent());
  }
 public AdsAmazonObject verifyNoAdsFromAmazonPresent() {
   Assertion.assertFalse(checkIfElementOnPage(By.cssSelector(AMAZON_SLOTS_CSS_SELECTOR)));
   PageObjectLogging.log("AmazonAd", "No Amazon ad present", true);
   return this;
 }
  public PortableInfoboxObject areOrderedListsVisible() {
    Assertion.assertFalse(orderedLists.isEmpty());
    PageObjectLogging.log("Ordered list", MercuryMessages.VISIBLE_MSG, true);

    return this;
  }
  public PortableInfoboxObject areHeadersVisible() {
    Assertion.assertFalse(headers.isEmpty());
    PageObjectLogging.log("Headers", MercuryMessages.VISIBLE_MSG, true);

    return this;
  }
  public PortableInfoboxObject areLinksVisible() {
    Assertion.assertFalse(externalLinks.isEmpty());
    PageObjectLogging.log("Links", MercuryMessages.VISIBLE_MSG, true);

    return this;
  }
  public PortableInfoboxObject areDataValuesVisible() {
    Assertion.assertFalse(dataValues.isEmpty());
    PageObjectLogging.log("Data values", MercuryMessages.VISIBLE_MSG, true);

    return this;
  }
  public String getExternalLinkName(int index) {
    Assertion.assertFalse(externalLinks.isEmpty());
    wait.forElementVisible(externalLinks.get(index));

    return externalLinks.get(index).getText();
  }
  // TODO: This is not real tap, replace with PerformTouchActions class methods
  public PortableInfoboxObject tapInfoboxContent() {
    Assertion.assertFalse(dataLabels.isEmpty());
    dataLabels.get(0).click();

    return this;
  }