-
Notifications
You must be signed in to change notification settings - Fork 143
Seo 670 new tests #2517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sczerwinski-wikia
wants to merge
13
commits into
master
Choose a base branch
from
SEO-670-new-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Seo 670 new tests #2517
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2ddf52d
Renamed desktop CategoryPageObject to CategoryExhibitionPage
4465391
Moved Category exhibition to a new namespace
1d5ff0e
Pages and Components related to dynamic category page
6abb1ef
Changed the wait not to wait 15 seconds to get toString string
44cc212
Added dynamic category tests
71d467e
Increase invocationCount for every test for dynamic categories
0c3a368
Added common category group for mobile and desktop category tests and…
aab2b22
Merge branch 'master' into SEO-670-new-tests
494412a
Renamed element and removed getComponent method as it's no longer needed
75579ad
Merge branch 'SEO-670-new-tests' of github.com:Wikia/selenium-tests i…
c81e0a7
Removed TODO from PaginationControls
5942f22
Rename DynamicCategoryTests to DynamicCategoryPageTests
3ea8919
Merge branch 'master' into SEO-670-new-tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
.../webdriver/elements/communities/desktop/components/categories/CategoryLayoutSelector.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
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 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); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...ikia/webdriver/elements/communities/desktop/components/categories/PaginationControls.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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<T> 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; | ||
} | ||
|
||
public boolean isFirstButtonIsVisible() { | ||
return isVisible(firstButton); | ||
} | ||
|
||
public boolean isNextButtonVisible() { | ||
return isVisible(nextButton); | ||
} | ||
|
||
public boolean isPreviousButtonVisible() { | ||
return isVisible(previousButton); | ||
} | ||
|
||
public boolean isLastButtonVisible() { | ||
return isVisible(lastButton); | ||
} | ||
|
||
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; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...om/wikia/webdriver/elements/communities/desktop/pages/categories/DynamicCategoryPage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = new CategoryLayoutSelector(); | ||
@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<WebElement> 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); | ||
} | ||
|
||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
.../java/com/wikia/webdriver/testcases/desktop/categoriestests/DynamicCategoryPageTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
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; | ||
|
||
@Test(groups = {"Category, Oasis_Category"}) | ||
@Execute(onWikia = "category") | ||
public class DynamicCategoryPageTests extends NewTestTemplate { | ||
|
||
|
||
public void dynamicCategoryAnonNotAbleToChangeLayout() { | ||
new ArticlePageObject().open("Category:200elements"); | ||
|
||
DynamicCategoryPage categoryPage = new DynamicCategoryPage(); | ||
CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); | ||
Assertion.assertFalse(layoutSelector.isVisible(), "Layout selectors are displayed for anon"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
/** | ||
* Category exhibition is set as default for USER | ||
*/ | ||
@Execute(asUser = User.USER) | ||
public void categoryExhibitionSetInPreferencesAsDefaultView() { | ||
new ArticlePageObject().open("Category:200elements"); | ||
|
||
DynamicCategoryPage categoryPage = new DynamicCategoryPage(); | ||
CategoryLayoutSelector layoutSelector = categoryPage.getLayoutSelector(); | ||
Assertion.assertTrue(layoutSelector.isCategoryExhibitionActive()); | ||
|
||
} | ||
|
||
@Execute(asUser = User.USER) | ||
public void dynamicCategoryLoggedInUserCanChangeLayout() { | ||
new ArticlePageObject().open("Category:200elements"); | ||
|
||
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); | ||
} | ||
|
||
/** | ||
* Default settings (dynamic category) are applied for USER_2 | ||
*/ | ||
@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()); | ||
} | ||
|
||
@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"); | ||
} | ||
|
||
@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<WebElement> memberList = categoryPage.getMembers(); | ||
|
||
Assertion.assertEquals(categoryPage.getMembers().size(), 1); | ||
Assertion.assertTrue(memberList.stream().anyMatch(e->"Article99".equals(e.getText()))); | ||
paginationControls.clickFirstButton(); | ||
|
||
memberList = categoryPage.getMembers(); | ||
Assertion.assertTrue(memberList.stream().anyMatch(e->"Article1".equals(e.getText()))); | ||
} | ||
|
||
@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()); | ||
} | ||
|
||
@Execute(asUser = User.USER_2) | ||
public void subcategoriesAreMixedWithArticles() { | ||
new ArticlePageObject().open("Category:Articles"); | ||
|
||
DynamicCategoryPage categoryPage = new DynamicCategoryPage(); | ||
List<WebElement> memberList = categoryPage.getMembers(); | ||
Assertion.assertTrue( | ||
memberList.stream().anyMatch(m -> m.getText().matches("(?:Category|Kategoria):TestArticles")), | ||
"Category cannot be found in the list" | ||
); | ||
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.