Skip to content
Snippets Groups Projects
Commit 2506ffe9 authored by srosse's avatar srosse
Browse files

OO-1068: 1 selenium test for blog (author, participant and clear cache between)

parent 3d7ea821
No related branches found
No related tags found
No related merge requests found
Showing
with 425 additions and 27 deletions
...@@ -88,16 +88,20 @@ public class OverviewRepositoryListController extends BasicController implements ...@@ -88,16 +88,20 @@ public class OverviewRepositoryListController extends BasicController implements
segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this); segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this);
favoriteLink = LinkFactory.createLink("search.mark", mainVC, this); favoriteLink = LinkFactory.createLink("search.mark", mainVC, this);
favoriteLink.setElementCssClass("o_sel_mycourses_fav");
segmentView.addSegment(favoriteLink, false); segmentView.addSegment(favoriteLink, false);
myCourseLink = LinkFactory.createLink("search.mycourses.student", mainVC, this); myCourseLink = LinkFactory.createLink("search.mycourses.student", mainVC, this);
myCourseLink.setElementCssClass("o_sel_mycourses_my");
segmentView.addSegment(myCourseLink, false); segmentView.addSegment(myCourseLink, false);
if(repositoryModule.isCatalogEnabled() && repositoryModule.isCatalogBrowsingEnabled()) { if(repositoryModule.isCatalogEnabled() && repositoryModule.isCatalogBrowsingEnabled()) {
catalogLink = LinkFactory.createLink("search.catalog", mainVC, this); catalogLink = LinkFactory.createLink("search.catalog", mainVC, this);
catalogLink.setElementCssClass("o_sel_mycourses_catlog");
segmentView.addSegment(catalogLink, false); segmentView.addSegment(catalogLink, false);
} }
if(repositoryModule.isMyCoursesSearchEnabled()) { if(repositoryModule.isMyCoursesSearchEnabled()) {
searchCourseLink = LinkFactory.createLink("search.courses.student", mainVC, this); searchCourseLink = LinkFactory.createLink("search.courses.student", mainVC, this);
searchCourseLink.setElementCssClass("o_sel_mycourses_search");
segmentView.addSegment(searchCourseLink, false); segmentView.addSegment(searchCourseLink, false);
} }
......
...@@ -91,6 +91,7 @@ public class RepositoryEntrySearchController extends FormBasicController impleme ...@@ -91,6 +91,7 @@ public class RepositoryEntrySearchController extends FormBasicController impleme
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator()); FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout); formLayout.add(buttonLayout);
searchButton = uifactory.addFormSubmitButton("search", buttonLayout); searchButton = uifactory.addFormSubmitButton("search", buttonLayout);
searchButton.setElementCssClass("o_sel_repo_search_button");
if(cancelAllowed) { if(cancelAllowed) {
uifactory.addFormCancelButton("quick.search", buttonLayout, ureq, getWindowControl()); uifactory.addFormCancelButton("quick.search", buttonLayout, ureq, getWindowControl());
} }
......
...@@ -37,8 +37,10 @@ import org.jboss.arquillian.test.api.ArquillianResource; ...@@ -37,8 +37,10 @@ import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.olat.selenium.page.Administrator;
import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.LoginPage;
import org.olat.selenium.page.NavigationPage; 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.CourseEditorPageFragment;
import org.olat.selenium.page.course.CoursePageFragment; import org.olat.selenium.page.course.CoursePageFragment;
import org.olat.selenium.page.course.CourseWizardPage; import org.olat.selenium.page.course.CourseWizardPage;
...@@ -535,4 +537,107 @@ public class CourseTest { ...@@ -535,4 +537,107 @@ public class CourseTest {
WebElement subscriptionLink = browser.findElement(By.cssSelector("div.o_subscription>a")); WebElement subscriptionLink = browser.findElement(By.cssSelector("div.o_subscription>a"));
Assert.assertTrue(subscriptionLink.isDisplayed()); 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);
}
} }
...@@ -300,7 +300,7 @@ public class PortfolioTest { ...@@ -300,7 +300,7 @@ public class PortfolioTest {
String blogNodeTitle = "Blog-EP-1"; String blogNodeTitle = "Blog-EP-1";
String blogTitle = "Blog - EP - " + UUID.randomUUID().toString(); 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); CourseEditorPageFragment courseEditor = CourseEditorPageFragment.getEditor(browser);
courseEditor courseEditor
.createNode("blog") .createNode("blog")
...@@ -326,7 +326,7 @@ public class PortfolioTest { ...@@ -326,7 +326,7 @@ public class PortfolioTest {
FeedPage feed = FeedPage.getFeedPage(browser); FeedPage feed = FeedPage.getFeedPage(browser);
ArtefactWizardPage artefactWizard = feed ArtefactWizardPage artefactWizard = feed
.newBlog() .newBlog()
.newBlogPost(postTitle, postSummary, postContent) .fillPostForm(postTitle, postSummary, postContent)
.publishPost() .publishPost()
.addAsArtfeact(); .addAsArtfeact();
...@@ -553,7 +553,7 @@ public class PortfolioTest { ...@@ -553,7 +553,7 @@ public class PortfolioTest {
FeedPage feed = FeedPage.getFeedPage(browser); FeedPage feed = FeedPage.getFeedPage(browser);
feed feed
.newBlog() .newBlog()
.newBlogPost(postTitle, postSummary, postContent) .fillPostForm(postTitle, postSummary, postContent)
.publishPost(); .publishPost();
//check that we see the post //check that we see the post
...@@ -631,7 +631,7 @@ public class PortfolioTest { ...@@ -631,7 +631,7 @@ public class PortfolioTest {
FeedPage feed = FeedPage.getFeedPage(browser); FeedPage feed = FeedPage.getFeedPage(browser);
feed feed
.newBlog() .newBlog()
.newBlogPost(postTitle, postSummary, postContent) .fillPostForm(postTitle, postSummary, postContent)
.publishPost(); .publishPost();
//check that we see the post //check that we see the post
......
/**
* <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 {
}
...@@ -24,6 +24,8 @@ import java.util.List; ...@@ -24,6 +24,8 @@ import java.util.List;
import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.Graphene; import org.jboss.arquillian.graphene.Graphene;
import org.junit.Assert; 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.graphene.OOGraphene;
import org.olat.selenium.page.group.GroupsPage; import org.olat.selenium.page.group.GroupsPage;
import org.olat.selenium.page.repository.AuthoringEnvPage; import org.olat.selenium.page.repository.AuthoringEnvPage;
...@@ -57,6 +59,14 @@ public class NavigationPage { ...@@ -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 myCoursesAssertBy = By.xpath("//div[contains(@class,'o_segments')]//a[contains(@href,'search.mycourses.student')]");
public static final By portalAssertBy = By.className("o_portal"); public static final By portalAssertBy = By.className("o_portal");
public NavigationPage() {
//
}
public NavigationPage(WebDriver browser) {
this.browser = browser;
}
public NavigationPage assertOnNavigationPage() { public NavigationPage assertOnNavigationPage() {
WebElement navigationSites = browser.findElement(navigationSitesBy); WebElement navigationSites = browser.findElement(navigationSitesBy);
Assert.assertTrue(navigationSites.isDisplayed()); Assert.assertTrue(navigationSites.isDisplayed());
...@@ -79,17 +89,19 @@ public class NavigationPage { ...@@ -79,17 +89,19 @@ public class NavigationPage {
return Graphene.createPageFragment(PortalPage.class, main); return Graphene.createPageFragment(PortalPage.class, main);
} }
public void openMyCourses() { public MyCoursesPage openMyCourses() {
navigate(myCoursesBy); navigate(myCoursesBy);
OOGraphene.waitElement(myCoursesAssertBy); OOGraphene.waitElement(myCoursesAssertBy);
return new MyCoursesPage(browser);
} }
public void openUserManagement() { public void openUserManagement() {
navigate(userManagementBy); navigate(userManagementBy);
} }
public void openAdministration() { public AdministrationPage openAdministration() {
navigate(administrationBy); navigate(administrationBy);
return new AdministrationPage(browser);
} }
public GroupsPage openGroups(WebDriver browser) { public GroupsPage openGroups(WebDriver browser) {
......
/**
* <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;
}
}
...@@ -21,11 +21,12 @@ package org.olat.selenium.page.core; ...@@ -21,11 +21,12 @@ package org.olat.selenium.page.core;
import java.util.List; import java.util.List;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.junit.Assert; import org.junit.Assert;
import org.olat.selenium.page.graphene.OOGraphene; import org.olat.selenium.page.graphene.OOGraphene;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
/** /**
* Fragment which contains the menu tree. The WebElement to create * Fragment which contains the menu tree. The WebElement to create
...@@ -37,8 +38,18 @@ import org.openqa.selenium.support.FindBy; ...@@ -37,8 +38,18 @@ import org.openqa.selenium.support.FindBy;
*/ */
public class MenuTreePageFragment { public class MenuTreePageFragment {
@FindBy(className="o_tree") private static final By treeBy = By.className("o_tree");
private WebElement tree;
@Drone
private WebDriver browser;
public MenuTreePageFragment() {
//
}
public MenuTreePageFragment(WebDriver browser) {
this.browser = browser;
}
/** /**
* Click the root link in the tree. * Click the root link in the tree.
...@@ -46,6 +57,7 @@ public class MenuTreePageFragment { ...@@ -46,6 +57,7 @@ public class MenuTreePageFragment {
* @return The menu page fragment * @return The menu page fragment
*/ */
public MenuTreePageFragment selectRoot() { public MenuTreePageFragment selectRoot() {
WebElement tree = browser.findElement(treeBy);
List<WebElement> rootLinks = tree.findElements(By.cssSelector("a.o_tree_link")); List<WebElement> rootLinks = tree.findElements(By.cssSelector("a.o_tree_link"));
Assert.assertNotNull(rootLinks); Assert.assertNotNull(rootLinks);
Assert.assertFalse(rootLinks.isEmpty()); Assert.assertFalse(rootLinks.isEmpty());
...@@ -57,7 +69,7 @@ public class MenuTreePageFragment { ...@@ -57,7 +69,7 @@ public class MenuTreePageFragment {
public MenuTreePageFragment selectWithTitle(String title) { public MenuTreePageFragment selectWithTitle(String title) {
boolean found = false; boolean found = false;
WebElement tree = browser.findElement(treeBy);
List<WebElement> nodeLinks = tree.findElements(By.cssSelector("li>div>a.o_tree_link")); List<WebElement> nodeLinks = tree.findElements(By.cssSelector("li>div>a.o_tree_link"));
for(WebElement nodeLink:nodeLinks) { for(WebElement nodeLink:nodeLinks) {
String text = nodeLink.getText(); String text = nodeLink.getText();
......
...@@ -23,7 +23,6 @@ import java.net.URL; ...@@ -23,7 +23,6 @@ import java.net.URL;
import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.Graphene; import org.jboss.arquillian.graphene.Graphene;
import org.jboss.arquillian.graphene.fragment.Root;
import org.junit.Assert; import org.junit.Assert;
import org.olat.restapi.support.vo.CourseVO; import org.olat.restapi.support.vo.CourseVO;
import org.olat.selenium.page.core.MenuTreePageFragment; import org.olat.selenium.page.core.MenuTreePageFragment;
...@@ -31,7 +30,6 @@ import org.olat.selenium.page.graphene.OOGraphene; ...@@ -31,7 +30,6 @@ import org.olat.selenium.page.graphene.OOGraphene;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
/** /**
* *
...@@ -45,30 +43,33 @@ public class CoursePageFragment { ...@@ -45,30 +43,33 @@ public class CoursePageFragment {
public static final By toolsMenu = By.cssSelector("ul.o_sel_course_tools"); 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 toolsMenuCaret = By.cssSelector("a.o_sel_course_tools");
public static final By editCourseBy = By.className("o_sel_course_editor"); public static final By editCourseBy = By.className("o_sel_course_editor");
public static final By treeContainerBy = By.id("o_main_left_content");
@Drone @Drone
private WebDriver browser; private WebDriver browser;
@Root public CoursePageFragment() {
private WebElement main; //
}
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) { public static CoursePageFragment getCourse(WebDriver browser, URL deploymentUrl, CourseVO course) {
browser.navigate().to(deploymentUrl.toExternalForm() + "url/RepositoryEntry/" + course.getRepoEntryKey()); browser.navigate().to(deploymentUrl.toExternalForm() + "url/RepositoryEntry/" + course.getRepoEntryKey());
OOGraphene.waitElement(courseRun); OOGraphene.waitElement(courseRun);
WebElement main = browser.findElement(By.id("o_main")); return new CoursePageFragment(browser);
return Graphene.createPageFragment(CoursePageFragment.class, main);
} }
public static CoursePageFragment getCourse(WebDriver browser) { public static CoursePageFragment getCourse(WebDriver browser) {
OOGraphene.waitElement(courseRun); OOGraphene.waitElement(courseRun);
WebElement main = browser.findElement(By.id("o_main")); return new CoursePageFragment(browser);
return Graphene.createPageFragment(CoursePageFragment.class, main);
} }
public CoursePageFragment assertOnCoursePage() { public CoursePageFragment assertOnCoursePage() {
WebElement treeContainer = browser.findElement(treeContainerBy);
Assert.assertTrue(treeContainer.isDisplayed()); Assert.assertTrue(treeContainer.isDisplayed());
return this; return this;
} }
...@@ -78,7 +79,7 @@ public class CoursePageFragment { ...@@ -78,7 +79,7 @@ public class CoursePageFragment {
* @return * @return
*/ */
public MenuTreePageFragment clickTree() { public MenuTreePageFragment clickTree() {
MenuTreePageFragment menuTree = Graphene.createPageFragment(MenuTreePageFragment.class, treeContainer); MenuTreePageFragment menuTree = new MenuTreePageFragment(browser);
menuTree.selectRoot(); menuTree.selectRoot();
return menuTree; return menuTree;
} }
......
/**
* <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();
}
}
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
*/ */
package org.olat.selenium.page.repository; package org.olat.selenium.page.repository;
import org.jboss.arquillian.drone.api.annotation.Drone; import java.util.List;
import org.jboss.arquillian.graphene.Graphene;
import org.junit.Assert;
import org.olat.selenium.page.graphene.OOGraphene; import org.olat.selenium.page.graphene.OOGraphene;
import org.olat.selenium.page.portfolio.ArtefactWizardPage; import org.olat.selenium.page.portfolio.ArtefactWizardPage;
import org.openqa.selenium.By; import org.openqa.selenium.By;
...@@ -40,13 +41,36 @@ public class FeedPage { ...@@ -40,13 +41,36 @@ public class FeedPage {
public static final By newExternalFeedBy = By.className("o_feed"); public static final By newExternalFeedBy = By.className("o_feed");
@Drone
private WebDriver browser; private WebDriver browser;
public FeedPage(WebDriver browser) {
this.browser = browser;
}
public static FeedPage getFeedPage(WebDriver browser) { public static FeedPage getFeedPage(WebDriver browser) {
OOGraphene.waitElement(feedBy); OOGraphene.waitElement(feedBy);
WebElement main = browser.findElement(feedBy); return new FeedPage(browser);
return Graphene.createPageFragment(FeedPage.class, main); }
/**
* 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 { ...@@ -60,6 +84,11 @@ public class FeedPage {
return newExternalFeed(lastButton, url); return newExternalFeed(lastButton, url);
} }
/**
* Create a new external blog.
* @param url
* @return
*/
public FeedPage newExternalBlog(String url) { public FeedPage newExternalBlog(String url) {
//click the button to create an external feed //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')]"); By lastButton = By.xpath("//div[contains(@class,'o_blog_no_posts')]//a[contains(@href,'feed.make.external')]");
...@@ -90,7 +119,14 @@ public class FeedPage { ...@@ -90,7 +119,14 @@ public class FeedPage {
return this; 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']"); By titleBy = By.cssSelector("div.o_sel_blog_title input[type='text']");
browser.findElement(titleBy).sendKeys(title); browser.findElement(titleBy).sendKeys(title);
...@@ -119,4 +155,18 @@ public class FeedPage { ...@@ -119,4 +155,18 @@ public class FeedPage {
OOGraphene.waitBusy(); OOGraphene.waitBusy();
return ArtefactWizardPage.getWizard(browser); 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment