diff --git a/src/main/java/org/olat/repository/ui/list/OverviewRepositoryListController.java b/src/main/java/org/olat/repository/ui/list/OverviewRepositoryListController.java index f7496d1bf35677de769af66ac218449a9804241a..ffecef90216c824c614cf8d9f145cb2210f6a48f 100644 --- a/src/main/java/org/olat/repository/ui/list/OverviewRepositoryListController.java +++ b/src/main/java/org/olat/repository/ui/list/OverviewRepositoryListController.java @@ -88,16 +88,20 @@ public class OverviewRepositoryListController extends BasicController implements segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this); favoriteLink = LinkFactory.createLink("search.mark", mainVC, this); + favoriteLink.setElementCssClass("o_sel_mycourses_fav"); segmentView.addSegment(favoriteLink, false); myCourseLink = LinkFactory.createLink("search.mycourses.student", mainVC, this); + myCourseLink.setElementCssClass("o_sel_mycourses_my"); segmentView.addSegment(myCourseLink, false); if(repositoryModule.isCatalogEnabled() && repositoryModule.isCatalogBrowsingEnabled()) { catalogLink = LinkFactory.createLink("search.catalog", mainVC, this); + catalogLink.setElementCssClass("o_sel_mycourses_catlog"); segmentView.addSegment(catalogLink, false); } if(repositoryModule.isMyCoursesSearchEnabled()) { searchCourseLink = LinkFactory.createLink("search.courses.student", mainVC, this); + searchCourseLink.setElementCssClass("o_sel_mycourses_search"); segmentView.addSegment(searchCourseLink, false); } diff --git a/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java b/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java index bc657fb949c7ee9cc7bcd33ea739eb5681daa596..9701782ba43a23d147ac40eeda2784a8c06be879 100644 --- a/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java +++ b/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java @@ -91,6 +91,7 @@ public class RepositoryEntrySearchController extends FormBasicController impleme FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator()); formLayout.add(buttonLayout); searchButton = uifactory.addFormSubmitButton("search", buttonLayout); + searchButton.setElementCssClass("o_sel_repo_search_button"); if(cancelAllowed) { uifactory.addFormCancelButton("quick.search", buttonLayout, ureq, getWindowControl()); } diff --git a/src/test/java/org/olat/selenium/CourseTest.java b/src/test/java/org/olat/selenium/CourseTest.java index 7cd1ac27505a60e15ceb3a71044116fdf30fd4c3..f269953d78bf8404301605bd812cebbf1e003b3b 100644 --- a/src/test/java/org/olat/selenium/CourseTest.java +++ b/src/test/java/org/olat/selenium/CourseTest.java @@ -37,8 +37,10 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; +import org.olat.selenium.page.Administrator; import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.NavigationPage; +import org.olat.selenium.page.Participant; import org.olat.selenium.page.course.CourseEditorPageFragment; import org.olat.selenium.page.course.CoursePageFragment; import org.olat.selenium.page.course.CourseWizardPage; @@ -535,4 +537,107 @@ public class CourseTest { WebElement subscriptionLink = browser.findElement(By.cssSelector("div.o_subscription>a")); Assert.assertTrue(subscriptionLink.isDisplayed()); } + + /** + * An author create a course with a blog, open it, add a post. + * A student open the course, see the blog post. An administrator + * clears the feed cache. The author add a new post, the student + * must see it. + * + * @param loginPage + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void blogWithClearCache(@InitialPage LoginPage loginPage, + @Drone @Participant WebDriver participantDrone, + @Drone @Administrator WebDriver administratorDrone) + throws IOException, URISyntaxException { + + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + UserVO participant = new UserRestClient(deploymentUrl).createRandomUser(); + + loginPage.loginAs(author.getLogin(), author.getPassword()); + + //create a course with a blog + String courseTitle = "Course-Blog-1-" + UUID.randomUUID().toString(); + navBar + .openAuthoringEnvironment() + .createCourse(courseTitle) + .clickToolbarBack() + .edit(); + + String blogNodeTitle = "Blog-RW-1"; + String blogTitle = "Blog - RW - " + UUID.randomUUID().toString(); + + //create a course element of type blog with a blog + CourseEditorPageFragment courseEditor = CourseEditorPageFragment.getEditor(browser); + courseEditor + .createNode("blog") + .nodeTitle(blogNodeTitle) + .selectTabLearnContent() + .createFeed(blogTitle); + //publish the course + courseEditor + .publish() + .quickPublish(); + + //open the course and see the blog + CoursePageFragment course = courseEditor + .clickToolbarBack(); + course + .clickTree() + .selectWithTitle(blogNodeTitle); + + String postTitle = "Blog-RW-1-" + UUID.randomUUID(); + String postSummary = "Some explantations as teaser"; + String postContent = "Content of the post"; + FeedPage feed = FeedPage.getFeedPage(browser); + feed + .newBlog() + .fillPostForm(postTitle, postSummary, postContent) + .publishPost(); + + //participant go to the blog + participantDrone.navigate().to(deploymentUrl); + LoginPage participantLogin = LoginPage.getLoginPage(participantDrone, deploymentUrl); + participantLogin.loginAs(participant.getLogin(), participant.getPassword()); + //search the course in "My courses" + NavigationPage participantNavigation = new NavigationPage(participantDrone); + participantNavigation + .openMyCourses() + .openSearch() + .search(courseTitle) + .select(courseTitle) + .start(); + //Navigate the course to the blog + CoursePageFragment participantCourse = new CoursePageFragment(participantDrone); + participantCourse + .clickTree() + .selectWithTitle(blogNodeTitle); + FeedPage participantFeed = FeedPage.getFeedPage(participantDrone); + participantFeed.assertOnBlogPost(postTitle); + + //administrator clears the cache + administratorDrone.navigate().to(deploymentUrl); + LoginPage.getLoginPage(administratorDrone, deploymentUrl) + .loginAs("administrator", "openolat"); + new NavigationPage(administratorDrone) + .openAdministration() + .clearCache("FeedManager@feed"); + + //the author publish a second post in its blog + String post2Title = "Blog-RW-2-" + UUID.randomUUID(); + String post2Summary = "Some explantations as teaser"; + String post2Content = "Content of the post"; + feed.addPost() + .fillPostForm(post2Title, post2Summary, post2Content) + .publishPost(); + + //the participant must see the new post after some click + participantFeed + .clickFirstMonthOfPager() + .assertOnBlogPost(post2Title); + } } diff --git a/src/test/java/org/olat/selenium/PortfolioTest.java b/src/test/java/org/olat/selenium/PortfolioTest.java index 3e7b14d7b9ffb231e3432856153c46a8ea0e005c..731d7c938ec16c40c283a133a0193c21fe41ee75 100644 --- a/src/test/java/org/olat/selenium/PortfolioTest.java +++ b/src/test/java/org/olat/selenium/PortfolioTest.java @@ -300,7 +300,7 @@ public class PortfolioTest { String blogNodeTitle = "Blog-EP-1"; String blogTitle = "Blog - EP - " + UUID.randomUUID().toString(); - //create a course element of type CP with the CP that we create above + //create a course element of type blog with a blog CourseEditorPageFragment courseEditor = CourseEditorPageFragment.getEditor(browser); courseEditor .createNode("blog") @@ -326,7 +326,7 @@ public class PortfolioTest { FeedPage feed = FeedPage.getFeedPage(browser); ArtefactWizardPage artefactWizard = feed .newBlog() - .newBlogPost(postTitle, postSummary, postContent) + .fillPostForm(postTitle, postSummary, postContent) .publishPost() .addAsArtfeact(); @@ -553,7 +553,7 @@ public class PortfolioTest { FeedPage feed = FeedPage.getFeedPage(browser); feed .newBlog() - .newBlogPost(postTitle, postSummary, postContent) + .fillPostForm(postTitle, postSummary, postContent) .publishPost(); //check that we see the post @@ -631,7 +631,7 @@ public class PortfolioTest { FeedPage feed = FeedPage.getFeedPage(browser); feed .newBlog() - .newBlogPost(postTitle, postSummary, postContent) + .fillPostForm(postTitle, postSummary, postContent) .publishPost(); //check that we see the post diff --git a/src/test/java/org/olat/selenium/page/Administrator.java b/src/test/java/org/olat/selenium/page/Administrator.java new file mode 100644 index 0000000000000000000000000000000000000000..244b497bb833252f6b053a559c3312c5ceba31be --- /dev/null +++ b/src/test/java/org/olat/selenium/page/Administrator.java @@ -0,0 +1,40 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.selenium.page; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.jboss.arquillian.drone.api.annotation.Qualifier; + +/** + * + * Initial date: 07.07.2014<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.FIELD, ElementType.PARAMETER }) +@Qualifier +public @interface Administrator { + +} diff --git a/src/test/java/org/olat/selenium/page/NavigationPage.java b/src/test/java/org/olat/selenium/page/NavigationPage.java index d8918ddb03f83f42dcfb0516e26540bd7dc5b6b6..2655ddadd60c37419c7a462723c890326d870602 100644 --- a/src/test/java/org/olat/selenium/page/NavigationPage.java +++ b/src/test/java/org/olat/selenium/page/NavigationPage.java @@ -24,6 +24,8 @@ import java.util.List; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.graphene.Graphene; import org.junit.Assert; +import org.olat.selenium.page.core.AdministrationPage; +import org.olat.selenium.page.course.MyCoursesPage; import org.olat.selenium.page.graphene.OOGraphene; import org.olat.selenium.page.group.GroupsPage; import org.olat.selenium.page.repository.AuthoringEnvPage; @@ -57,6 +59,14 @@ public class NavigationPage { public static final By myCoursesAssertBy = By.xpath("//div[contains(@class,'o_segments')]//a[contains(@href,'search.mycourses.student')]"); public static final By portalAssertBy = By.className("o_portal"); + public NavigationPage() { + // + } + + public NavigationPage(WebDriver browser) { + this.browser = browser; + } + public NavigationPage assertOnNavigationPage() { WebElement navigationSites = browser.findElement(navigationSitesBy); Assert.assertTrue(navigationSites.isDisplayed()); @@ -79,17 +89,19 @@ public class NavigationPage { return Graphene.createPageFragment(PortalPage.class, main); } - public void openMyCourses() { + public MyCoursesPage openMyCourses() { navigate(myCoursesBy); OOGraphene.waitElement(myCoursesAssertBy); + return new MyCoursesPage(browser); } public void openUserManagement() { navigate(userManagementBy); } - public void openAdministration() { + public AdministrationPage openAdministration() { navigate(administrationBy); + return new AdministrationPage(browser); } public GroupsPage openGroups(WebDriver browser) { diff --git a/src/test/java/org/olat/selenium/page/core/AdministrationPage.java b/src/test/java/org/olat/selenium/page/core/AdministrationPage.java new file mode 100644 index 0000000000000000000000000000000000000000..f225944fb49a1eb62056c5c35d2bba285da6c374 --- /dev/null +++ b/src/test/java/org/olat/selenium/page/core/AdministrationPage.java @@ -0,0 +1,80 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.selenium.page.core; + +import java.util.List; + +import org.jboss.arquillian.drone.api.annotation.Drone; +import org.junit.Assert; +import org.olat.selenium.page.graphene.OOGraphene; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +/** + * Drive the administration site + * + * Initial date: 07.07.2014<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class AdministrationPage { + + //private static final By + + @Drone + private WebDriver browser; + + public AdministrationPage() { + // + } + + public AdministrationPage(WebDriver browser) { + this.browser = browser; + } + + public AdministrationPage clearCache(String cacheName) { + //system tree node + WebElement systemLink = browser.findElement(By.xpath("//div[contains(@class,'o_tree')]//a[contains(@href,'systemParent/')]")); + systemLink.click(); + OOGraphene.waitBusy(); + //cache tree node + WebElement cacheLink = browser.findElement(By.cssSelector(".o_sel_caches a.o_tree_level_label_leaf")); + cacheLink.click(); + OOGraphene.waitBusy(); + //table + WebElement emptyLink = null; + List<WebElement> rows = browser.findElements(By.cssSelector(".o_table_wrapper table>tbody>tr")); + for(WebElement row:rows) { + if(row.getText().contains(cacheName)) { + emptyLink = row.findElement(By.tagName("a")); + } + } + Assert.assertNotNull(emptyLink); + //click to empty + emptyLink.click(); + OOGraphene.waitBusy(); + //confirm + WebElement yesLink = browser.findElement(By.xpath("//div[contains(@class,'modal-dialog')]//a[contains(@href,'link_0')]")); + yesLink.click(); + OOGraphene.waitBusy(); + return this; + } +} diff --git a/src/test/java/org/olat/selenium/page/core/MenuTreePageFragment.java b/src/test/java/org/olat/selenium/page/core/MenuTreePageFragment.java index 755156ccf1e176e55bcdf9e2a79eaa1940177eb2..e97e49ed7ee61a33290f2d41b494fbb79ed773ac 100644 --- a/src/test/java/org/olat/selenium/page/core/MenuTreePageFragment.java +++ b/src/test/java/org/olat/selenium/page/core/MenuTreePageFragment.java @@ -21,11 +21,12 @@ package org.olat.selenium.page.core; import java.util.List; +import org.jboss.arquillian.drone.api.annotation.Drone; import org.junit.Assert; import org.olat.selenium.page.graphene.OOGraphene; import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.FindBy; /** * Fragment which contains the menu tree. The WebElement to create @@ -37,8 +38,18 @@ import org.openqa.selenium.support.FindBy; */ public class MenuTreePageFragment { - @FindBy(className="o_tree") - private WebElement tree; + private static final By treeBy = By.className("o_tree"); + + @Drone + private WebDriver browser; + + public MenuTreePageFragment() { + // + } + + public MenuTreePageFragment(WebDriver browser) { + this.browser = browser; + } /** * Click the root link in the tree. @@ -46,6 +57,7 @@ public class MenuTreePageFragment { * @return The menu page fragment */ public MenuTreePageFragment selectRoot() { + WebElement tree = browser.findElement(treeBy); List<WebElement> rootLinks = tree.findElements(By.cssSelector("a.o_tree_link")); Assert.assertNotNull(rootLinks); Assert.assertFalse(rootLinks.isEmpty()); @@ -57,7 +69,7 @@ public class MenuTreePageFragment { public MenuTreePageFragment selectWithTitle(String title) { boolean found = false; - + WebElement tree = browser.findElement(treeBy); List<WebElement> nodeLinks = tree.findElements(By.cssSelector("li>div>a.o_tree_link")); for(WebElement nodeLink:nodeLinks) { String text = nodeLink.getText(); diff --git a/src/test/java/org/olat/selenium/page/course/CoursePageFragment.java b/src/test/java/org/olat/selenium/page/course/CoursePageFragment.java index 8669bcc88d2e88cbd8284205106d4c8c3f81eb05..78a927cb4f7e19c8f5b30a8e1923a478b6ce3e88 100644 --- a/src/test/java/org/olat/selenium/page/course/CoursePageFragment.java +++ b/src/test/java/org/olat/selenium/page/course/CoursePageFragment.java @@ -23,7 +23,6 @@ import java.net.URL; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.graphene.Graphene; -import org.jboss.arquillian.graphene.fragment.Root; import org.junit.Assert; import org.olat.restapi.support.vo.CourseVO; import org.olat.selenium.page.core.MenuTreePageFragment; @@ -31,7 +30,6 @@ import org.olat.selenium.page.graphene.OOGraphene; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.FindBy; /** * @@ -45,30 +43,33 @@ public class CoursePageFragment { public static final By toolsMenu = By.cssSelector("ul.o_sel_course_tools"); public static final By toolsMenuCaret = By.cssSelector("a.o_sel_course_tools"); public static final By editCourseBy = By.className("o_sel_course_editor"); + public static final By treeContainerBy = By.id("o_main_left_content"); @Drone private WebDriver browser; - @Root - private WebElement main; + public CoursePageFragment() { + // + } + + public CoursePageFragment(WebDriver browser) { + this.browser = browser; + } - @FindBy(id="o_main_left_content") - private WebElement treeContainer; public static CoursePageFragment getCourse(WebDriver browser, URL deploymentUrl, CourseVO course) { browser.navigate().to(deploymentUrl.toExternalForm() + "url/RepositoryEntry/" + course.getRepoEntryKey()); OOGraphene.waitElement(courseRun); - WebElement main = browser.findElement(By.id("o_main")); - return Graphene.createPageFragment(CoursePageFragment.class, main); + return new CoursePageFragment(browser); } public static CoursePageFragment getCourse(WebDriver browser) { OOGraphene.waitElement(courseRun); - WebElement main = browser.findElement(By.id("o_main")); - return Graphene.createPageFragment(CoursePageFragment.class, main); + return new CoursePageFragment(browser); } public CoursePageFragment assertOnCoursePage() { + WebElement treeContainer = browser.findElement(treeContainerBy); Assert.assertTrue(treeContainer.isDisplayed()); return this; } @@ -78,7 +79,7 @@ public class CoursePageFragment { * @return */ public MenuTreePageFragment clickTree() { - MenuTreePageFragment menuTree = Graphene.createPageFragment(MenuTreePageFragment.class, treeContainer); + MenuTreePageFragment menuTree = new MenuTreePageFragment(browser); menuTree.selectRoot(); return menuTree; } diff --git a/src/test/java/org/olat/selenium/page/course/MyCoursesPage.java b/src/test/java/org/olat/selenium/page/course/MyCoursesPage.java new file mode 100644 index 0000000000000000000000000000000000000000..f0555b09ce8d375680a6340565d8e6c4ccd22031 --- /dev/null +++ b/src/test/java/org/olat/selenium/page/course/MyCoursesPage.java @@ -0,0 +1,93 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.selenium.page.course; + +import java.util.List; + +import org.jboss.arquillian.drone.api.annotation.Drone; +import org.junit.Assert; +import org.olat.selenium.page.graphene.OOGraphene; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +/** + * Drive the "My courses" site + * + * Initial date: 07.07.2014<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class MyCoursesPage { + + @Drone + private WebDriver browser; + + public MyCoursesPage() { + // + } + + public MyCoursesPage(WebDriver browser) { + this.browser = browser; + } + + public MyCoursesPage openSearch() { + By searchBy = By.className("o_sel_mycourses_search"); + WebElement searchLink = browser.findElement(searchBy); + searchLink.click(); + OOGraphene.waitBusy(); + return this; + } + + public MyCoursesPage search(String title) { + By titleBy = By.cssSelector(".o_sel_repo_search_displayname input[type='text']"); + WebElement titleEl = browser.findElement(titleBy); + titleEl.sendKeys(title); + + By searchButton = By.className("o_sel_repo_search_button"); + WebElement searchEl = browser.findElement(searchButton); + searchEl.click(); + OOGraphene.waitBusy(); + return this; + } + + public MyCoursesPage select(String title) { + By titleLinkBy = By.cssSelector("h4.o_title a"); + WebElement linkToSelect = null; + List<WebElement> titleLinks = browser.findElements(titleLinkBy); + for(WebElement link :titleLinks) { + if(link.getText().contains(title)) { + linkToSelect = link; + } + } + Assert.assertNotNull(linkToSelect); + linkToSelect.click(); + OOGraphene.waitBusy(); + return this; + } + + public void start() { + By startBy = By.className("o_start"); + WebElement startLink = browser.findElement(startBy); + startLink.click(); + OOGraphene.waitBusy(); + } + +} diff --git a/src/test/java/org/olat/selenium/page/repository/FeedPage.java b/src/test/java/org/olat/selenium/page/repository/FeedPage.java index c6725ad624d3611a6783301b1c705092ef0cd6e5..2112d4b8eb94d3bebb06edb659ad5969ab984195 100644 --- a/src/test/java/org/olat/selenium/page/repository/FeedPage.java +++ b/src/test/java/org/olat/selenium/page/repository/FeedPage.java @@ -19,8 +19,9 @@ */ package org.olat.selenium.page.repository; -import org.jboss.arquillian.drone.api.annotation.Drone; -import org.jboss.arquillian.graphene.Graphene; +import java.util.List; + +import org.junit.Assert; import org.olat.selenium.page.graphene.OOGraphene; import org.olat.selenium.page.portfolio.ArtefactWizardPage; import org.openqa.selenium.By; @@ -40,13 +41,36 @@ public class FeedPage { public static final By newExternalFeedBy = By.className("o_feed"); - @Drone + private WebDriver browser; + public FeedPage(WebDriver browser) { + this.browser = browser; + } + + public static FeedPage getFeedPage(WebDriver browser) { OOGraphene.waitElement(feedBy); - WebElement main = browser.findElement(feedBy); - return Graphene.createPageFragment(FeedPage.class, main); + return new FeedPage(browser); + } + + /** + * Check that the post is visible + * @param title + * @return + */ + public FeedPage assertOnBlogPost(String title) { + //assert on post + boolean found = false; + By postTitleBy = By.cssSelector(".o_post h3.o_title>a>span"); + List<WebElement> postTitleEls = browser.findElements(postTitleBy); + for(WebElement postTitleEl:postTitleEls) { + if(postTitleEl.getText().contains(title)) { + found = true; + } + } + Assert.assertTrue(found); + return this; } /** @@ -60,6 +84,11 @@ public class FeedPage { return newExternalFeed(lastButton, url); } + /** + * Create a new external blog. + * @param url + * @return + */ public FeedPage newExternalBlog(String url) { //click the button to create an external feed By lastButton = By.xpath("//div[contains(@class,'o_blog_no_posts')]//a[contains(@href,'feed.make.external')]"); @@ -90,7 +119,14 @@ public class FeedPage { return this; } - public FeedPage newBlogPost(String title, String summary, String content) { + public FeedPage addPost() { + By newItemButton = By.className("o_sel_feed_item_new"); + browser.findElement(newItemButton).click(); + OOGraphene.waitBusy(); + return this; + } + + public FeedPage fillPostForm(String title, String summary, String content) { By titleBy = By.cssSelector("div.o_sel_blog_title input[type='text']"); browser.findElement(titleBy).sendKeys(title); @@ -119,4 +155,18 @@ public class FeedPage { OOGraphene.waitBusy(); return ArtefactWizardPage.getWizard(browser); } + + /** + * Click the first month in the pager + * @return + */ + public FeedPage clickFirstMonthOfPager() { + By monthBy = By.cssSelector("div.o_year_navigation ul.o_month>li.o_month>a.o_month"); + List<WebElement> monthLinks = browser.findElements(monthBy); + System.out.println(monthLinks.size()); + Assert.assertFalse(monthLinks.isEmpty()); + monthLinks.get(0).click(); + OOGraphene.waitBusy(); + return this; + } } \ No newline at end of file