From 2ddf52d17c4537489ded04713a66792def32ee42 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Thu, 8 Nov 2018 13:54:33 +0100 Subject: [PATCH 01/10] Renamed desktop CategoryPageObject to CategoryExhibitionPage --- .../pageobjectsfactory/pageobject/PortableInfobox.java | 10 +++++----- ...goryPageObject.java => CategoryExhibitionPage.java} | 2 +- .../portableinfoboxtests/PortableInfoboxTests.java | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) rename src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/{CategoryPageObject.java => CategoryExhibitionPage.java} (95%) diff --git a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java index 54cfdb0e45..5bdc3f5422 100644 --- a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java +++ b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java @@ -3,7 +3,7 @@ import com.wikia.webdriver.common.core.Assertion; import com.wikia.webdriver.common.logging.Log; import com.wikia.webdriver.pageobjectsfactory.componentobject.modalwindows.CreateArticleModalComponentObject; -import com.wikia.webdriver.pageobjectsfactory.pageobject.category.CategoryPageObject; +import com.wikia.webdriver.pageobjectsfactory.pageobject.category.CategoryExhibitionPage; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; @@ -195,18 +195,18 @@ public PortableInfobox clickImage() { return this; } - public CategoryPageObject clickCategoryLink() { + public CategoryExhibitionPage clickCategoryLink() { wait.forElementVisible(categoryLinkInInfobox); scrollAndClick(categoryLinkInInfobox); - return new CategoryPageObject(); + return new CategoryExhibitionPage(); } - public CategoryPageObject clickCategoryWithIndex(int index) { + public CategoryExhibitionPage clickCategoryWithIndex(int index) { wait.forElementVisible(categories.get(index)); scrollAndClick(categories.get(index)); - return new CategoryPageObject(); + return new CategoryExhibitionPage(); } public PortableInfobox open(String articleTitle) { diff --git a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryPageObject.java b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryExhibitionPage.java similarity index 95% rename from src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryPageObject.java rename to src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryExhibitionPage.java index 15cf885c3b..5eb7751ec1 100644 --- a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryPageObject.java +++ b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryExhibitionPage.java @@ -10,7 +10,7 @@ import java.util.List; -public class CategoryPageObject extends WikiBasePageObject { +public class CategoryExhibitionPage extends WikiBasePageObject { @FindBy(css = ".category-gallery-item") private List categoryGalleryItems; diff --git a/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java b/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java index dc64ffdf65..35a7740072 100644 --- a/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java +++ b/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java @@ -15,7 +15,7 @@ import com.wikia.webdriver.pageobjectsfactory.pageobject.PortableInfobox; import com.wikia.webdriver.pageobjectsfactory.pageobject.article.ArticlePageObject; import com.wikia.webdriver.pageobjectsfactory.pageobject.article.editmode.SourceEditModePageObject; -import com.wikia.webdriver.pageobjectsfactory.pageobject.category.CategoryPageObject; +import com.wikia.webdriver.pageobjectsfactory.pageobject.category.CategoryExhibitionPage; import com.wikia.webdriver.pageobjectsfactory.pageobject.special.SpecialWhatLinksHerePageObject; import com.wikia.webdriver.pageobjectsfactory.pageobject.special.themedesigner.SpecialThemeDesignerPageObject; import com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject; @@ -198,7 +198,7 @@ public void verifyInfoboxCategoryLinks() { String categoryLinkName = infobox.getCategoryLinkName(); infobox.clickCategoryLink(); - String categoryPageTitle = new CategoryPageObject().getCategoryPageTitle(); + String categoryPageTitle = new CategoryExhibitionPage().getCategoryPageTitle(); Assertion.assertTrue(categoryLinkName.contains(categoryPageTitle)); } @@ -373,10 +373,10 @@ public void infoboxImageOnCategoryPage() { String imageName = infobox.getDataImageName(); - CategoryPageObject categoryPage = infobox.clickCategoryWithIndex(0); + CategoryExhibitionPage categoryExhibitionPage = infobox.clickCategoryWithIndex(0); new ArticlePurger().purgeArticleAsLoggedUser(); - String categoryImageURL = categoryPage.getImageURLFromGallery(PageContent.INFOBOX_2); + String categoryImageURL = categoryExhibitionPage.getImageURLFromGallery(PageContent.INFOBOX_2); Assertion.assertTrue(categoryImageURL.contains(imageName)); } From 4465391d8da8b83328cbd99e45dd361ddde2d7e6 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Thu, 8 Nov 2018 14:09:14 +0100 Subject: [PATCH 02/10] Moved Category exhibition to a new namespace --- .../desktop/pages/categories}/CategoryExhibitionPage.java | 2 +- .../pageobjectsfactory/pageobject/PortableInfobox.java | 2 +- .../infobox/portableinfoboxtests/PortableInfoboxTests.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/test/java/com/wikia/webdriver/{pageobjectsfactory/pageobject/category => elements/communities/desktop/pages/categories}/CategoryExhibitionPage.java (94%) diff --git a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryExhibitionPage.java b/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/CategoryExhibitionPage.java similarity index 94% rename from src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryExhibitionPage.java rename to src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/CategoryExhibitionPage.java index 5eb7751ec1..a7022f86ae 100644 --- a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/category/CategoryExhibitionPage.java +++ b/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/CategoryExhibitionPage.java @@ -1,4 +1,4 @@ -package com.wikia.webdriver.pageobjectsfactory.pageobject.category; +package com.wikia.webdriver.elements.communities.desktop.pages.categories; import com.wikia.webdriver.common.logging.Log; import com.wikia.webdriver.pageobjectsfactory.pageobject.WikiBasePageObject; diff --git a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java index 5bdc3f5422..28fd149481 100644 --- a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java +++ b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/PortableInfobox.java @@ -3,7 +3,7 @@ import com.wikia.webdriver.common.core.Assertion; import com.wikia.webdriver.common.logging.Log; import com.wikia.webdriver.pageobjectsfactory.componentobject.modalwindows.CreateArticleModalComponentObject; -import com.wikia.webdriver.pageobjectsfactory.pageobject.category.CategoryExhibitionPage; +import com.wikia.webdriver.elements.communities.desktop.pages.categories.CategoryExhibitionPage; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; diff --git a/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java b/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java index 35a7740072..71e7f388c1 100644 --- a/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java +++ b/src/test/java/com/wikia/webdriver/testcases/desktop/infobox/portableinfoboxtests/PortableInfoboxTests.java @@ -15,7 +15,7 @@ import com.wikia.webdriver.pageobjectsfactory.pageobject.PortableInfobox; import com.wikia.webdriver.pageobjectsfactory.pageobject.article.ArticlePageObject; import com.wikia.webdriver.pageobjectsfactory.pageobject.article.editmode.SourceEditModePageObject; -import com.wikia.webdriver.pageobjectsfactory.pageobject.category.CategoryExhibitionPage; +import com.wikia.webdriver.elements.communities.desktop.pages.categories.CategoryExhibitionPage; import com.wikia.webdriver.pageobjectsfactory.pageobject.special.SpecialWhatLinksHerePageObject; import com.wikia.webdriver.pageobjectsfactory.pageobject.special.themedesigner.SpecialThemeDesignerPageObject; import com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject; From 1d5ff0e83040525145bba713bdde74e51580bea2 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Tue, 13 Nov 2018 13:11:20 +0100 Subject: [PATCH 03/10] Pages and Components related to dynamic category page --- .../categories/CategoryLayoutSelector.java | 59 +++++++++++++ .../categories/PaginationControls.java | 88 +++++++++++++++++++ .../pages/categories/DynamicCategoryPage.java | 63 +++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java create mode 100644 src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java create mode 100644 src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java diff --git a/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java new file mode 100644 index 0000000000..e3bf0eed8f --- /dev/null +++ b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java @@ -0,0 +1,59 @@ +package com.wikia.webdriver.elements.communities.desktop.components.categories; + +import com.wikia.webdriver.elements.communities.desktop.pages.categories.CategoryExhibitionPage; +import com.wikia.webdriver.elements.communities.desktop.pages.categories.DynamicCategoryPage; +import com.wikia.webdriver.pageobjectsfactory.pageobject.BasePageObject; + +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +/** + * This component lets user choose category page layout, it's available only for logged in users + */ +public class CategoryLayoutSelector extends BasePageObject { + + @FindBy(css = "li[data-category-layout=mediawiki]") + private WebElement classicViewButton; + @FindBy(css = "li[data-category-layout=category-exhibition]") + private WebElement categoryExhibitionButton; + @FindBy(css = "li[data-category-layout=category-page3]") + private WebElement dynamicViewButton; + @FindBy(css = ".category-layout-selector") + private WebElement ViewContainer; + + public static CategoryLayoutSelector getComponent() { + //TODO: Chack if user is logged in, if not throw exception + + return new CategoryLayoutSelector(); + } + + private CategoryLayoutSelector() { + + } + + public boolean isCategoryExhibitionActive() { + return categoryExhibitionButton.getAttribute("class").contains("is-active"); + } + + public boolean isDynamicViewActive() { + return dynamicViewButton.getAttribute("class").contains("is-active"); + } + + public void switchToClassicView() { + classicViewButton.click(); + } + + public CategoryExhibitionPage switchToCategoryExhibitionView() { + categoryExhibitionButton.click(); + return new CategoryExhibitionPage(); + } + + public DynamicCategoryPage switchToDynamicCategoriesView() { + dynamicViewButton.click(); + return new DynamicCategoryPage(); + } + + public boolean isVisible() { + return isVisible(ViewContainer); + } +} diff --git a/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java new file mode 100644 index 0000000000..cc58eb4da2 --- /dev/null +++ b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java @@ -0,0 +1,88 @@ +package com.wikia.webdriver.elements.communities.desktop.components.categories; + +import com.wikia.webdriver.common.logging.Log; +import com.wikia.webdriver.pageobjectsfactory.pageobject.BasePageObject; + +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +public class PaginationControls extends BasePageObject { + + private final T outer; + @FindBy(xpath = "//a[contains(text(),'First')]") + private WebElement firstButton; + @FindBy(css = ".category-page__pagination-next") + private WebElement nextButton; + @FindBy(css = ".category-page__pagination-prev") + private WebElement previousButton; + @FindBy(xpath = "//a[contains(text(),'Last')]") + private WebElement lastButton; + + public PaginationControls (T outer) { + this.outer = outer; + } + + //TODO:Check if it actually works + public boolean isFirstButtonIsVisible() { + + boolean isVisible = isVisible(firstButton); +// Log.info("Next page button is visible."); + + return isVisible; + } + + //TODO:Check if it actually works + public boolean isNextButtonVisible() { + + boolean isVisible = isVisible(nextButton); +// Log.info("Next page button is visible."); + + return isVisible; + } + + //TODO:Check if it actually works + public boolean isPreviousButtonVisible() { + + boolean isVisible = isVisible(previousButton); +// Log.info("Previous page button is visible."); + + return isVisible; + } + + //TODO:Check if it actually works + public boolean isLastButtonVisible() { + + boolean isVisible = isVisible(lastButton); +// Log.info("Next page button is visible."); + + return isVisible; + } + + public T clickFirstButton() { + this.scrollAndClick(firstButton); + Log.info("First page button clicked."); + + return outer; + } + + public T clickNextButton() { + this.scrollAndClick(nextButton); + Log.info("Next page button clicked."); + + return outer; + } + + public T clickPreviousButton() { + this.scrollAndClick(previousButton); + Log.info("Previous page button clicked."); + + return outer; + } + + public T clickLastButton() { + this.scrollAndClick(lastButton); + Log.info("Last page button clicked."); + + return outer; + } +} diff --git a/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java b/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java new file mode 100644 index 0000000000..feca7af073 --- /dev/null +++ b/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java @@ -0,0 +1,63 @@ +package com.wikia.webdriver.elements.communities.desktop.pages.categories; + +import com.wikia.webdriver.common.logging.Log; +import com.wikia.webdriver.elements.communities.desktop.components.categories.CategoryLayoutSelector; +import com.wikia.webdriver.elements.communities.desktop.components.categories.PaginationControls; +import com.wikia.webdriver.pageobjectsfactory.pageobject.WikiBasePageObject; + +import lombok.Getter; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DynamicCategoryPage extends WikiBasePageObject { + + @FindBy(css=".article-content") + private WebElement articleContent; + + + private By categoryMembersContainer = By.cssSelector(".category-members-grouped"); + private By categoryMembers = By.cssSelector(".category-page__members li a"); + + @Getter(lazy = true) + private final CategoryLayoutSelector layoutSelector = CategoryLayoutSelector.getComponent(); + @Getter(lazy = true) + private final PaginationControls paginationControls = new PaginationControls(this); + + public String getArticleContent() { + return articleContent.getText(); + } + + public boolean categoryMembersContainerIsVisible() { + wait.forElementVisible(categoryMembersContainer); + Log.info("Category members container is visible."); + + return true; + } + + public boolean hasCategoryMembers() { + wait.forElementVisible(categoryMembers); + Log.info("Category has members."); + + return driver.findElements(categoryMembers).size() > 0; + } + + public List getMembers() { + return driver.findElements(categoryMembers); + } + + public String getNumberOfElementsInCategory() { + Pattern pattern = Pattern.compile("(?:All items )\\((.d)\\)"); + Matcher matcher = pattern.matcher("test"); + if (matcher.group().isEmpty()) { + throw new IllegalArgumentException("Unable to extract number of elements in the category"); + } + return matcher.group(0); + } + + +} From 6abb1ef55c66dda680b8f58f5a1f83975ac4b251 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Tue, 13 Nov 2018 13:12:22 +0100 Subject: [PATCH 04/10] Changed the wait not to wait 15 seconds to get toString string --- .../pageobjectsfactory/pageobject/BasePageObject.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/BasePageObject.java b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/BasePageObject.java index 04edc91ded..721ad900b8 100644 --- a/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/BasePageObject.java +++ b/src/test/java/com/wikia/webdriver/pageobjectsfactory/pageobject/BasePageObject.java @@ -747,11 +747,14 @@ public void enterEmailChangeLink(String email, String password) { public boolean isVisible(WebElement element) { boolean result; + try { wait.forElementVisible(element); result = true; } catch (TimeoutException e) { + changeImplicitWait(0, TimeUnit.MILLISECONDS); Log.info("Element: " + element.toString() + " not found.", e); + restoreDefaultImplicitWait(); result = false; } return result; From 44cc212ed855d82d5d827b2e9d92398f302f6382 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Tue, 13 Nov 2018 13:13:22 +0100 Subject: [PATCH 05/10] Added dynamic category tests --- .../categoriestests/DynamicCategoryTests.java | 114 ++++++++++++++++++ .../wikia/webdriver/testsuites/testSuite.xml | 1 + 2 files changed, 115 insertions(+) create mode 100644 src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java diff --git a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java new file mode 100644 index 0000000000..2cd2ab1647 --- /dev/null +++ b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java @@ -0,0 +1,114 @@ +package com.wikia.webdriver.testcases.desktop.categoriestests; + +import com.wikia.webdriver.common.core.Assertion; +import com.wikia.webdriver.common.core.annotations.Execute; +import com.wikia.webdriver.common.core.helpers.User; +import com.wikia.webdriver.common.templates.NewTestTemplate; +import com.wikia.webdriver.elements.communities.desktop.components.categories.CategoryLayoutSelector; +import com.wikia.webdriver.elements.communities.desktop.components.categories.PaginationControls; +import com.wikia.webdriver.elements.communities.desktop.pages.categories.DynamicCategoryPage; +import com.wikia.webdriver.pageobjectsfactory.pageobject.article.ArticlePageObject; + +import org.openqa.selenium.WebElement; +import org.testng.annotations.Test; + +import java.util.List; + +@Execute(onWikia = "category") +public class DynamicCategoryTests extends NewTestTemplate { + + @Test(groups = {"DynamicCategoryTests"}) + public void dynamicCategoryAnonNotAbleToChangeLayout() { + new ArticlePageObject().open("Category:Wikia_tests"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); + Assertion.assertFalse(layoutSelector.isVisible(), "Layout selectors are displayed for anon"); + } + + @Test(groups = {"DynamicCategoryTests"}) + @Execute(asUser = User.USER) + public void categoryExhibitionSetInPreferencesAsDefaultView() { + new ArticlePageObject().open("Category:Wikia_tests"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); + Assertion.assertTrue(layoutSelector.isCategoryExhibitionActive()); + + } + + @Test(groups = {"DynamicCategoryTests"}) + @Execute(asUser = User.USER) + public void dynamicCategoryLoggedInUserCanChangeLayout() { + new ArticlePageObject().open("Category:Wikia_tests"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); + Assertion.assertTrue(layoutSelector.isVisible(), "Layout selectors are displayed for anon"); + String pageUrl = categoryPage.getCurrentUrl(); + layoutSelector.switchToDynamicCategoriesView(); + Assertion.assertStringContains(categoryPage.getCurrentUrl(), pageUrl); + } + + @Test(groups = {"DynamicCategoryTests"}) + @Execute(asUser = User.USER_2) + public void pagination200elementsNoNextButton() { + new ArticlePageObject().open("Category:200elements"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); + Assertion.assertTrue(layoutSelector.isDynamicViewActive()); + PaginationControls paginationControls = categoryPage.getPaginationControls(); + Assertion.assertFalse(paginationControls.isNextButtonVisible()); + } + + @Test(groups = {"DynamicCategoryTests"}) + @Execute(asUser = User.USER_2) + public void pagination201elementsNextButtonVisible() { + new ArticlePageObject().open("Category:201elements"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); + Assertion.assertEquals(layoutSelector.isDynamicViewActive(), true, "Dynamic view is not active"); + PaginationControls paginationControls = categoryPage.getPaginationControls(); + paginationControls.clickNextButton(); + Assertion.assertEquals(categoryPage.getMembers().size(), 1, "Invalid number of members on category page"); + } + + @Test(groups = {"DynamicCategoryTests"}) + @Execute(asUser = User.USER_2) + public void pagination401elementsNextButtonVisible() { + new ArticlePageObject().open("Category:401elements"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); + Assertion.assertEquals(layoutSelector.isDynamicViewActive(), true, "Dynamic view is not active"); + PaginationControls paginationControls = categoryPage.getPaginationControls(); + Assertion.assertTrue(paginationControls.isNextButtonVisible(), "Next button is not visible"); + Assertion.assertTrue(paginationControls.isLastButtonVisible(), "Last button is not visible"); + paginationControls.clickLastButton(); + + List memberList = categoryPage.getMembers(); + + Assertion.assertEquals(categoryPage.getMembers().size(), 1); + Assertion.assertTrue(memberList.stream().anyMatch(e->e.getText().equals("Article99"))); + paginationControls.clickFirstButton(); + + memberList = categoryPage.getMembers(); + Assertion.assertTrue(memberList.stream().anyMatch(e->e.getText().equals("Article1"))); + } + + @Test(groups = {"DynamicCategoryTests"}) + @Execute(asUser = User.USER_2) + public void overridingLayoutSetInPreferences() { + new ArticlePageObject().open("Category:201elements"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); + Assertion.assertTrue(layoutSelector.isVisible(), "Layout selectors are displayed for anon"); + Assertion.assertTrue(layoutSelector.isDynamicViewActive()); + layoutSelector.switchToCategoryExhibitionView(); + categoryPage.refreshPage(); + Assertion.assertTrue(layoutSelector.isCategoryExhibitionActive()); + } +} diff --git a/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml b/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml index 095e2c2a98..a67c7110f7 100644 --- a/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml +++ b/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml @@ -237,6 +237,7 @@ + From 71d467e37cb434dcfad6664f5b96b8d6fad28651 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Tue, 13 Nov 2018 13:16:01 +0100 Subject: [PATCH 06/10] Increase invocationCount for every test for dynamic categories --- .../desktop/categoriestests/DynamicCategoryTests.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java index 2cd2ab1647..7407e4505e 100644 --- a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java +++ b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java @@ -14,10 +14,11 @@ import java.util.List; +@Test(groups = {"DynamicCategoryTests"}, invocationCount = 5) @Execute(onWikia = "category") public class DynamicCategoryTests extends NewTestTemplate { - @Test(groups = {"DynamicCategoryTests"}) + public void dynamicCategoryAnonNotAbleToChangeLayout() { new ArticlePageObject().open("Category:Wikia_tests"); @@ -26,7 +27,6 @@ public void dynamicCategoryAnonNotAbleToChangeLayout() { Assertion.assertFalse(layoutSelector.isVisible(), "Layout selectors are displayed for anon"); } - @Test(groups = {"DynamicCategoryTests"}) @Execute(asUser = User.USER) public void categoryExhibitionSetInPreferencesAsDefaultView() { new ArticlePageObject().open("Category:Wikia_tests"); @@ -37,7 +37,6 @@ public void categoryExhibitionSetInPreferencesAsDefaultView() { } - @Test(groups = {"DynamicCategoryTests"}) @Execute(asUser = User.USER) public void dynamicCategoryLoggedInUserCanChangeLayout() { new ArticlePageObject().open("Category:Wikia_tests"); @@ -50,7 +49,6 @@ public void dynamicCategoryLoggedInUserCanChangeLayout() { Assertion.assertStringContains(categoryPage.getCurrentUrl(), pageUrl); } - @Test(groups = {"DynamicCategoryTests"}) @Execute(asUser = User.USER_2) public void pagination200elementsNoNextButton() { new ArticlePageObject().open("Category:200elements"); @@ -62,7 +60,6 @@ public void pagination200elementsNoNextButton() { Assertion.assertFalse(paginationControls.isNextButtonVisible()); } - @Test(groups = {"DynamicCategoryTests"}) @Execute(asUser = User.USER_2) public void pagination201elementsNextButtonVisible() { new ArticlePageObject().open("Category:201elements"); @@ -75,7 +72,6 @@ public void pagination201elementsNextButtonVisible() { Assertion.assertEquals(categoryPage.getMembers().size(), 1, "Invalid number of members on category page"); } - @Test(groups = {"DynamicCategoryTests"}) @Execute(asUser = User.USER_2) public void pagination401elementsNextButtonVisible() { new ArticlePageObject().open("Category:401elements"); @@ -98,7 +94,6 @@ public void pagination401elementsNextButtonVisible() { Assertion.assertTrue(memberList.stream().anyMatch(e->e.getText().equals("Article1"))); } - @Test(groups = {"DynamicCategoryTests"}) @Execute(asUser = User.USER_2) public void overridingLayoutSetInPreferences() { new ArticlePageObject().open("Category:201elements"); From 0c3a368591f0a6cf08bfb99cbe5ad7ace9bdf287 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Tue, 13 Nov 2018 15:05:17 +0100 Subject: [PATCH 07/10] Added common category group for mobile and desktop category tests and removed invocationCount --- .../testcases/desktop/categoriestests/DynamicCategoryTests.java | 2 +- .../webdriver/testcases/mobile/category/CategoryPageTest.java | 2 +- .../wikia/webdriver/testcases/mobile/category/CategoryTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java index 7407e4505e..5ba456c82a 100644 --- a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java +++ b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java @@ -14,7 +14,7 @@ import java.util.List; -@Test(groups = {"DynamicCategoryTests"}, invocationCount = 5) +@Test(groups = {"Category, Oasis_Category"}) @Execute(onWikia = "category") public class DynamicCategoryTests extends NewTestTemplate { diff --git a/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryPageTest.java b/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryPageTest.java index 7fe48c4059..b1e251bf6d 100644 --- a/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryPageTest.java +++ b/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryPageTest.java @@ -14,7 +14,7 @@ import org.testng.annotations.Test; -@Test(groups = "Mercury_Category") +@Test(groups = "Category, Mercury_Category") @Execute(onWikia = MobileWikis.MERCURY_AUTOMATION_TESTING) @InBrowser(browser = Browser.CHROME, emulator = Emulator.GOOGLE_NEXUS_5) public class CategoryPageTest extends NewTestTemplate { diff --git a/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryTest.java b/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryTest.java index 45f9e47aed..52e311104b 100644 --- a/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryTest.java +++ b/src/test/java/com/wikia/webdriver/testcases/mobile/category/CategoryTest.java @@ -11,7 +11,7 @@ import org.testng.annotations.Test; -@Test(groups = "Mercury_Category") +@Test(groups = "Category, Mercury_Category") @Execute(onWikia = MobileWikis.MERCURY_AUTOMATION_TESTING) @InBrowser(browser = Browser.CHROME, emulator = Emulator.GOOGLE_NEXUS_5) public class CategoryTest extends NewTestTemplate { From 494412a6c39d73d1554cd364ac7a02a49bdb6d05 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Tue, 13 Nov 2018 15:25:35 +0100 Subject: [PATCH 08/10] Renamed element and removed getComponent method as it's no longer needed --- .../categories/CategoryLayoutSelector.java | 14 ++------------ .../pages/categories/DynamicCategoryPage.java | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java index e3bf0eed8f..0a68c491e0 100644 --- a/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java +++ b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java @@ -19,17 +19,7 @@ public class CategoryLayoutSelector extends BasePageObject { @FindBy(css = "li[data-category-layout=category-page3]") private WebElement dynamicViewButton; @FindBy(css = ".category-layout-selector") - private WebElement ViewContainer; - - public static CategoryLayoutSelector getComponent() { - //TODO: Chack if user is logged in, if not throw exception - - return new CategoryLayoutSelector(); - } - - private CategoryLayoutSelector() { - - } + private WebElement viewContainer; public boolean isCategoryExhibitionActive() { return categoryExhibitionButton.getAttribute("class").contains("is-active"); @@ -54,6 +44,6 @@ public DynamicCategoryPage switchToDynamicCategoriesView() { } public boolean isVisible() { - return isVisible(ViewContainer); + return isVisible(viewContainer); } } diff --git a/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java b/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java index feca7af073..214357b7c0 100644 --- a/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java +++ b/src/test/java/com/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java @@ -24,7 +24,7 @@ public class DynamicCategoryPage extends WikiBasePageObject { private By categoryMembers = By.cssSelector(".category-page__members li a"); @Getter(lazy = true) - private final CategoryLayoutSelector layoutSelector = CategoryLayoutSelector.getComponent(); + private final CategoryLayoutSelector layoutSelector = new CategoryLayoutSelector(); @Getter(lazy = true) private final PaginationControls paginationControls = new PaginationControls(this); From c81e0a7fed6ba2231d90e1e92db99ea4977f4e57 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Tue, 13 Nov 2018 18:38:27 +0100 Subject: [PATCH 09/10] Removed TODO from PaginationControls and moved string literal to the left --- .../categories/PaginationControls.java | 28 +++---------------- .../categoriestests/DynamicCategoryTests.java | 4 +-- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java index cc58eb4da2..4ef73bc957 100644 --- a/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java +++ b/src/test/java/com/wikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java @@ -22,40 +22,20 @@ public PaginationControls (T outer) { this.outer = outer; } - //TODO:Check if it actually works public boolean isFirstButtonIsVisible() { - - boolean isVisible = isVisible(firstButton); -// Log.info("Next page button is visible."); - - return isVisible; + return isVisible(firstButton); } - //TODO:Check if it actually works public boolean isNextButtonVisible() { - - boolean isVisible = isVisible(nextButton); -// Log.info("Next page button is visible."); - - return isVisible; + return isVisible(nextButton); } - //TODO:Check if it actually works public boolean isPreviousButtonVisible() { - - boolean isVisible = isVisible(previousButton); -// Log.info("Previous page button is visible."); - - return isVisible; + return isVisible(previousButton); } - //TODO:Check if it actually works public boolean isLastButtonVisible() { - - boolean isVisible = isVisible(lastButton); -// Log.info("Next page button is visible."); - - return isVisible; + return isVisible(lastButton); } public T clickFirstButton() { diff --git a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java index 5ba456c82a..6bfaa61a6c 100644 --- a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java +++ b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java @@ -87,11 +87,11 @@ public void pagination401elementsNextButtonVisible() { List memberList = categoryPage.getMembers(); Assertion.assertEquals(categoryPage.getMembers().size(), 1); - Assertion.assertTrue(memberList.stream().anyMatch(e->e.getText().equals("Article99"))); + Assertion.assertTrue(memberList.stream().anyMatch(e->"Article99".equals(e.getText()))); paginationControls.clickFirstButton(); memberList = categoryPage.getMembers(); - Assertion.assertTrue(memberList.stream().anyMatch(e->e.getText().equals("Article1"))); + Assertion.assertTrue(memberList.stream().anyMatch(e->"Article1".equals(e.getText()))); } @Execute(asUser = User.USER_2) From 5942f226ab816b8498aa679b0349522c97e1ac76 Mon Sep 17 00:00:00 2001 From: Szymon Czerwinski Date: Wed, 14 Nov 2018 16:56:10 +0100 Subject: [PATCH 10/10] Rename DynamicCategoryTests to DynamicCategoryPageTests --- ...sts.java => DynamicCategoryPageTests.java} | 27 ++++++++++++++++--- .../wikia/webdriver/testsuites/testSuite.xml | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) rename src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/{DynamicCategoryTests.java => DynamicCategoryPageTests.java} (85%) diff --git a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryPageTests.java similarity index 85% rename from src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java rename to src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryPageTests.java index 6bfaa61a6c..739bd10526 100644 --- a/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryTests.java +++ b/src/test/java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryPageTests.java @@ -16,20 +16,23 @@ @Test(groups = {"Category, Oasis_Category"}) @Execute(onWikia = "category") -public class DynamicCategoryTests extends NewTestTemplate { +public class DynamicCategoryPageTests extends NewTestTemplate { public void dynamicCategoryAnonNotAbleToChangeLayout() { - new ArticlePageObject().open("Category:Wikia_tests"); + new ArticlePageObject().open("Category:200elements"); DynamicCategoryPage categoryPage = new DynamicCategoryPage(); CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); Assertion.assertFalse(layoutSelector.isVisible(), "Layout selectors are displayed for anon"); } + /** + * Category exhibition is set as default for USER + */ @Execute(asUser = User.USER) public void categoryExhibitionSetInPreferencesAsDefaultView() { - new ArticlePageObject().open("Category:Wikia_tests"); + new ArticlePageObject().open("Category:200elements"); DynamicCategoryPage categoryPage = new DynamicCategoryPage(); CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); @@ -39,7 +42,7 @@ public void categoryExhibitionSetInPreferencesAsDefaultView() { @Execute(asUser = User.USER) public void dynamicCategoryLoggedInUserCanChangeLayout() { - new ArticlePageObject().open("Category:Wikia_tests"); + new ArticlePageObject().open("Category:200elements"); DynamicCategoryPage categoryPage = new DynamicCategoryPage(); CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); @@ -49,6 +52,9 @@ public void dynamicCategoryLoggedInUserCanChangeLayout() { Assertion.assertStringContains(categoryPage.getCurrentUrl(), pageUrl); } + /** + * Default settings (dynamic category) are applied for USER_2 + */ @Execute(asUser = User.USER_2) public void pagination200elementsNoNextButton() { new ArticlePageObject().open("Category:200elements"); @@ -106,4 +112,17 @@ public void overridingLayoutSetInPreferences() { categoryPage.refreshPage(); Assertion.assertTrue(layoutSelector.isCategoryExhibitionActive()); } + + @Execute(asUser = User.USER_2) + public void subcategoriesAreMixedWithArticles() { + new ArticlePageObject().open("Category:Articles"); + + DynamicCategoryPage categoryPage = new DynamicCategoryPage(); + List memberList = categoryPage.getMembers(); + Assertion.assertTrue( + memberList.stream().anyMatch(m -> m.getText().matches("(?:Category|Kategoria):TestArticles")), + "Category cannot be found in the list" + ); + + } } diff --git a/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml b/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml index a67c7110f7..b55ede3cb5 100644 --- a/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml +++ b/src/test/java/com/wikia/webdriver/testsuites/testSuite.xml @@ -237,7 +237,7 @@ - +