diff --git a/src/main/java/org/olat/course/DisposedCourseRestartController.java b/src/main/java/org/olat/course/DisposedCourseRestartController.java index 0ea8d41c0f19e6b6b10f5a7dede36ad228969d0a..b53e10d43406eac01887f6a9074bfd091078592a 100644 --- a/src/main/java/org/olat/course/DisposedCourseRestartController.java +++ b/src/main/java/org/olat/course/DisposedCourseRestartController.java @@ -69,6 +69,7 @@ public class DisposedCourseRestartController extends BasicController { super(ureq, wControl); initialContent = createVelocityContainer("disposedcourserestart"); restartLink = LinkFactory.createButton("course.disposed.command.restart", initialContent, this); + restartLink.setElementCssClass("o_sel_course_restart"); this.courseRepositoryEntry = courseRepositoryEntry; panel = putInitialPanel(initialContent); } diff --git a/src/test/java/org/olat/selenium/AssessmentTest.java b/src/test/java/org/olat/selenium/AssessmentTest.java index 316aa8fca15b4680a6a9bbef98bbe26c00fe534c..c2ef243da053bb4fdcd58d2ad68490f76e173114 100644 --- a/src/test/java/org/olat/selenium/AssessmentTest.java +++ b/src/test/java/org/olat/selenium/AssessmentTest.java @@ -37,31 +37,29 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Assume; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.NavigationPage; import org.olat.selenium.page.Participant; -import org.olat.selenium.page.ScreenshotTestRule; import org.olat.selenium.page.Student; import org.olat.selenium.page.User; import org.olat.selenium.page.course.AssessmentCEConfigurationPage; import org.olat.selenium.page.course.AssessmentModePage; import org.olat.selenium.page.course.AssessmentToolPage; +import org.olat.selenium.page.course.BulkAssessmentPage.BulkAssessmentData; import org.olat.selenium.page.course.CourseEditorPageFragment; import org.olat.selenium.page.course.CoursePageFragment; import org.olat.selenium.page.course.GroupTaskConfigurationPage; import org.olat.selenium.page.course.GroupTaskPage; import org.olat.selenium.page.course.GroupTaskToCoachPage; import org.olat.selenium.page.course.MembersPage; -import org.olat.selenium.page.course.BulkAssessmentPage.BulkAssessmentData; import org.olat.selenium.page.course.PublisherPageFragment.Access; import org.olat.selenium.page.graphene.OOGraphene; import org.olat.selenium.page.group.GroupPage; import org.olat.selenium.page.qti.QTI12Page; -import org.olat.selenium.page.repository.ScormPage; import org.olat.selenium.page.repository.RepositoryAccessPage.UserAccess; +import org.olat.selenium.page.repository.ScormPage; import org.olat.selenium.page.user.UserToolsPage; import org.olat.test.ArquillianDeployments; import org.olat.test.JunitTestHelper; @@ -91,9 +89,6 @@ public class AssessmentTest { private WebDriver browser; @ArquillianResource private URL deploymentUrl; - @Rule - public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule(); - @Page private NavigationPage navBar; @@ -109,7 +104,6 @@ public class AssessmentTest { @RunAsClient public void qti12Test(@InitialPage LoginPage authorLoginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -206,7 +200,6 @@ public class AssessmentTest { public void qti12CourseWithAssessment(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -349,7 +342,6 @@ public class AssessmentTest { public void scormCourseWithAssessment(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser); //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -470,7 +462,6 @@ public class AssessmentTest { public void assessmentMode_manual(@InitialPage LoginPage authorLoginPage, @Drone @Student WebDriver ryomouBrowser, @Drone @Participant WebDriver kanuBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser, kanuBrowser); //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -616,7 +607,6 @@ public class AssessmentTest { public void certificatesManuallyGenerated(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver reiBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, reiBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); authorLoginPage.loginAs(author.getLogin(), author.getPassword()); @@ -691,7 +681,6 @@ public class AssessmentTest { public void certificatesGeneratedByTest(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver reiBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, reiBrowser); //create an author and a participant UserVO author = new UserRestClient(deploymentUrl).createAuthor(); @@ -791,7 +780,6 @@ public class AssessmentTest { public void assessmentCourseElement(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); @@ -889,7 +877,6 @@ public class AssessmentTest { @Drone @User WebDriver ryomouBrowser, @Drone @Participant WebDriver kanuBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser, kanuBrowser); //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -1078,7 +1065,6 @@ public class AssessmentTest { public void taskWithIndividuScoreAndRevision(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser); //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -1243,7 +1229,6 @@ public class AssessmentTest { @Drone @User WebDriver ryomouBrowser, @Drone @Participant WebDriver kanuBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser,kanuBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); diff --git a/src/test/java/org/olat/selenium/BusinessGroupTest.java b/src/test/java/org/olat/selenium/BusinessGroupTest.java index 9e8abd608944b14925ec28bee8df1bfa0b8cee46..2f6095c1dc54c70ad3247003b09c1c85ad179f0c 100644 --- a/src/test/java/org/olat/selenium/BusinessGroupTest.java +++ b/src/test/java/org/olat/selenium/BusinessGroupTest.java @@ -35,13 +35,11 @@ import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.NavigationPage; import org.olat.selenium.page.Participant; -import org.olat.selenium.page.ScreenshotTestRule; import org.olat.selenium.page.Student; import org.olat.selenium.page.User; import org.olat.selenium.page.core.IMPage; @@ -81,8 +79,6 @@ public class BusinessGroupTest { private URL deploymentUrl; @Page private NavigationPage navBar; - @Rule - public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule(); /** * Create a group, search it and delete it. @@ -95,7 +91,6 @@ public class BusinessGroupTest { @RunAsClient public void createDeleteBusinessGroup(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -131,7 +126,6 @@ public class BusinessGroupTest { public void groupMembersVisibility(@InitialPage LoginPage loginPage, @Drone @Participant WebDriver participantBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, participantBrowser); UserVO author = new UserRestClient(deploymentUrl).createRandomUser("Selena"); UserVO participant = new UserRestClient(deploymentUrl).createRandomUser("Aoi"); @@ -190,8 +184,6 @@ public class BusinessGroupTest { @RunAsClient public void collaborativeTools(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); - UserVO author = new UserRestClient(deploymentUrl).createRandomUser("Selena"); loginPage @@ -292,8 +284,6 @@ public class BusinessGroupTest { @Drone @Participant WebDriver participantBrowser, @Drone @Student WebDriver studentBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, participantBrowser, studentBrowser); - UserVO author = new UserRestClient(deploymentUrl).createRandomUser("Selena"); UserVO participant = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); UserVO student = new UserRestClient(deploymentUrl).createRandomUser("Asuka"); @@ -390,8 +380,6 @@ public class BusinessGroupTest { @Drone @Participant WebDriver kanuBrowser, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, kanuBrowser, ryomouBrowser); - UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("Kanu"); UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); @@ -500,8 +488,6 @@ public class BusinessGroupTest { @Drone @Participant WebDriver reiBrowser, @Drone @Student WebDriver kanuBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser, reiBrowser, kanuBrowser); - UserVO author = new UserRestClient(deploymentUrl).createAuthor(); authorLoginPage.loginAs(author.getLogin(), author.getPassword()); UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei"); @@ -614,7 +600,6 @@ public class BusinessGroupTest { public void enrollmentWithMultiEnrollment(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); authorLoginPage.loginAs(author.getLogin(), author.getPassword()); @@ -718,7 +703,6 @@ public class BusinessGroupTest { @Drone @Participant WebDriver reiBrowser, @Drone @Student WebDriver kanuBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser, reiBrowser, kanuBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei"); @@ -851,7 +835,6 @@ public class BusinessGroupTest { @Drone @Participant WebDriver reiBrowser, @Drone @Student WebDriver kanuBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser, reiBrowser, kanuBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei"); diff --git a/src/test/java/org/olat/selenium/CourseTest.java b/src/test/java/org/olat/selenium/CourseTest.java index 5283966b94287b3c00e68208089f138cfe3d5589..95c1997f5383d2a51b166193f5df0deee9d2f514 100644 --- a/src/test/java/org/olat/selenium/CourseTest.java +++ b/src/test/java/org/olat/selenium/CourseTest.java @@ -38,14 +38,12 @@ import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; -import org.junit.Rule; 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.ScreenshotTestRule; import org.olat.selenium.page.Student; import org.olat.selenium.page.User; import org.olat.selenium.page.core.BookingPage; @@ -58,15 +56,15 @@ import org.olat.selenium.page.course.ForumCEPage; import org.olat.selenium.page.course.InfoMessageCEPage; import org.olat.selenium.page.course.MembersPage; import org.olat.selenium.page.course.PublisherPageFragment; -import org.olat.selenium.page.course.RemindersPage; import org.olat.selenium.page.course.PublisherPageFragment.Access; +import org.olat.selenium.page.course.RemindersPage; import org.olat.selenium.page.forum.ForumPage; import org.olat.selenium.page.graphene.OOGraphene; import org.olat.selenium.page.repository.AuthoringEnvPage; +import org.olat.selenium.page.repository.AuthoringEnvPage.ResourceType; import org.olat.selenium.page.repository.CPPage; import org.olat.selenium.page.repository.FeedPage; import org.olat.selenium.page.repository.RepositoryAccessPage; -import org.olat.selenium.page.repository.AuthoringEnvPage.ResourceType; import org.olat.selenium.page.repository.RepositoryAccessPage.UserAccess; import org.olat.selenium.page.repository.RepositoryEditDescriptionPage; import org.olat.test.ArquillianDeployments; @@ -97,8 +95,6 @@ public class CourseTest { private URL deploymentUrl; @Page private NavigationPage navBar; - @Rule - public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule(); /** * An author create a course, jump to it, open the editor @@ -113,7 +109,6 @@ public class CourseTest { @RunAsClient public void createCourse(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -185,7 +180,6 @@ public class CourseTest { @RunAsClient public void createCourse_withWizard(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -246,7 +240,6 @@ public class CourseTest { public void concurrentEditCourse(@InitialPage LoginPage loginPage, @Drone @Participant WebDriver coAuthorBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, coAuthorBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO coAuthor = new UserRestClient(deploymentUrl).createAuthor(); @@ -336,6 +329,153 @@ public class CourseTest { .assertOnEditor(); } + /** + * An author create a course, a user see it.<br> + * The author change the course and publish it. The user + * must see a warning if the same node as been modified. + * + * @param loginPage + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void concurrentVisitAndPublish(@InitialPage LoginPage loginPage, + @Drone @User WebDriver ryomouBrowser) + throws IOException, URISyntaxException { + + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + loginPage.loginAs(author.getLogin(), author.getPassword()); + UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); + + //create a course + String courseTitle = "Course to publish-" + UUID.randomUUID().toString(); + navBar + .openAuthoringEnvironment() + .createCourse(courseTitle) + .clickToolbarBack(); + + //open course editor + CoursePageFragment course = CoursePageFragment.getCourse(browser); + CourseEditorPageFragment editor = course + .assertOnCoursePage() + .assertOnTitle(courseTitle) + .openToolsMenu() + .edit(); + + //create a course element of type info messages + String firstNodeTitle = "First node"; + String secondNodeTitle = "Second node"; + editor + .assertOnEditor() + .createNode("info") + .nodeTitle(firstNodeTitle) + .createNode("st") + .nodeTitle(secondNodeTitle) + .publish() + .quickPublish(Access.users); + + // The user opens the course + LoginPage ryomouLoginPage = LoginPage.getLoginPage(ryomouBrowser, deploymentUrl); + ryomouLoginPage + .loginAs(ryomou.getLogin(), ryomou.getPassword()) + .resume(); + NavigationPage ryomouNavBar = new NavigationPage(ryomouBrowser); + ryomouNavBar + .openMyCourses() + .openSearch() + .extendedSearch(courseTitle) + .select(courseTitle) + .start(); + CoursePageFragment ryomouCourse = new CoursePageFragment(ryomouBrowser); + MenuTreePageFragment ryomouCourseTree = ryomouCourse + .clickTree() + .selectWithTitle(firstNodeTitle); + + //The author make a change on node 2 + String changedNodeTitlev2 = "Changed 2 title"; + course = editor + .selectNode(secondNodeTitle) + .nodeTitle(changedNodeTitlev2) + .autoPublish(); + + //The user click the first node and the changed second node + ryomouCourseTree + .selectWithTitle(firstNodeTitle) + .selectWithTitle(changedNodeTitlev2); + ryomouCourse + .assertOnTitle(changedNodeTitlev2); + + //The author changed the second node + String changedNodeTitlev3 = "Changed 3 title"; + course = course.edit() + .selectNode(changedNodeTitlev2) + .nodeTitle(changedNodeTitlev3) + .autoPublish(); + + //The user wait the message + ryomouCourse + .assertOnRestart() + .clickRestart(); + ryomouCourseTree + .selectWithTitle(changedNodeTitlev3); + ryomouCourse + .assertOnTitle(changedNodeTitlev3); + } + + /** + * Test that renaming the root node is reflected after + * publishing. + * + * @param loginPage + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void courseRename(@InitialPage LoginPage loginPage) + throws IOException, URISyntaxException { + + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + loginPage.loginAs(author.getLogin(), author.getPassword()); + + //create a course + String courseTitle = "Course to rename-" + UUID.randomUUID().toString(); + navBar + .openAuthoringEnvironment() + .createCourse(courseTitle) + .clickToolbarBack(); + + //open course editor + CoursePageFragment course = CoursePageFragment.getCourse(browser); + CourseEditorPageFragment editor = course + .assertOnCoursePage() + .assertOnTitle(courseTitle) + .openToolsMenu() + .edit(); + + //create a course element of type info messages + course = editor + .assertOnEditor() + .createNode("info") + .autoPublish(); + //check that the root node has the name of the repository entry + course + .assertOnTitle(courseTitle); + + //rename the root node + String newCourseName = "Renamed course"; + course = course + .edit() + .selectRoot() + .nodeTitle(newCourseName) + .autoPublish(); + + //assert the changed name + course + .assertOnTitle(newCourseName); + } + /** * Create a course, create a CP, go the the course editor, * create a course element of type CP, select the CP which just created, @@ -350,7 +490,6 @@ public class CourseTest { @RunAsClient public void createCourseWithCP(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -414,7 +553,6 @@ public class CourseTest { @RunAsClient public void createCourseWithWiki(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -477,7 +615,6 @@ public class CourseTest { @RunAsClient public void createCourseWithWiki_createInCourseEditor(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -524,7 +661,6 @@ public class CourseTest { @RunAsClient public void createCourseWithQTITest(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -579,7 +715,6 @@ public class CourseTest { @RunAsClient public void createCourseWithPodcast_externalFeed(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -633,7 +768,6 @@ public class CourseTest { @RunAsClient public void createCourseWithBlog_externalFeed(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -699,7 +833,6 @@ public class CourseTest { @Drone @Participant WebDriver participantDrone, @Drone @Administrator WebDriver administratorDrone) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, participantDrone, administratorDrone); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO participant = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); @@ -803,7 +936,6 @@ public class CourseTest { public void catalogRoundTrip(@Drone @Administrator WebDriver adminBrowser, @Drone @User WebDriver userBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, adminBrowser, userBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); @@ -884,7 +1016,6 @@ public class CourseTest { @RunAsClient public void createCourseWithInfoMessages(@InitialPage LoginPage authorLoginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); authorLoginPage.loginAs(author.getLogin(), author.getPassword()); @@ -990,7 +1121,6 @@ public class CourseTest { public void courseBooking(@InitialPage LoginPage loginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -1075,7 +1205,6 @@ public class CourseTest { @RunAsClient public void courseReminders(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage.loginAs(author.getLogin(), author.getPassword()); @@ -1172,7 +1301,6 @@ public class CourseTest { @Drone @Participant WebDriver kanuBrowser, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, kanuBrowser, ryomouBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("Kanu"); @@ -1295,7 +1423,6 @@ public class CourseTest { @Drone @Participant WebDriver kanuBrowser, @Drone @Student WebDriver reiBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, kanuBrowser, reiBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("Kanu"); @@ -1427,7 +1554,6 @@ public class CourseTest { public void forumWithGuest(@InitialPage LoginPage loginPage, @Drone @User WebDriver guestBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, guestBrowser); loginPage .loginAs("administrator", "openolat") @@ -1547,7 +1673,6 @@ public class CourseTest { public void courseAccessRules(@InitialPage LoginPage loginPage, @Drone @Student WebDriver reiBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, reiBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("rei"); @@ -1683,7 +1808,6 @@ public class CourseTest { public void createContentPackage(@InitialPage LoginPage loginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, ryomouBrowser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); diff --git a/src/test/java/org/olat/selenium/LoginTest.java b/src/test/java/org/olat/selenium/LoginTest.java index 2257d5bbab68f141fb09fedc1842cd2d58a71618..99f759c3c505adc3340b615bb9b5165f00c13822 100644 --- a/src/test/java/org/olat/selenium/LoginTest.java +++ b/src/test/java/org/olat/selenium/LoginTest.java @@ -31,13 +31,11 @@ import org.jboss.arquillian.graphene.page.InitialPage; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.NavigationPage; import org.olat.selenium.page.Participant; -import org.olat.selenium.page.ScreenshotTestRule; import org.olat.selenium.page.Student; import org.olat.selenium.page.core.AdministrationMessagesPage; import org.olat.test.ArquillianDeployments; @@ -63,8 +61,6 @@ public class LoginTest { private WebDriver browser; @ArquillianResource private URL deploymentUrl; - @Rule - public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule(); /** * Test if the dmz can be loaded. @@ -73,7 +69,6 @@ public class LoginTest { @Test @RunAsClient public void loadIndex(@InitialPage LoginPage loginPage) { - screenshotTestRule.setBrowsers(browser); //check that the login page, or dmz is loaded loginPage.assertOnLoginPage(); } @@ -86,7 +81,6 @@ public class LoginTest { @Test @RunAsClient public void loginAsAdministrator(@InitialPage LoginPage loginPage) { - screenshotTestRule.setBrowsers(browser); //load dmz loginPage.assertOnLoginPage(); //login as administrator @@ -107,7 +101,6 @@ public class LoginTest { @RunAsClient public void loginAsNewUser(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); //create a random user UserRestClient userClient = new UserRestClient(deploymentUrl); UserVO user = userClient.createRandomUser(); @@ -137,7 +130,6 @@ public class LoginTest { @Drone @Participant WebDriver reiBrowser, @Drone @Student WebDriver kanuBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, reiBrowser, kanuBrowser); UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei"); UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("Kanu"); diff --git a/src/test/java/org/olat/selenium/PortfolioTest.java b/src/test/java/org/olat/selenium/PortfolioTest.java index a8115752937c056e12c5ba698664a3a9a57d71b6..07decc2036e1a5de1c58651560e313f307b7e041 100644 --- a/src/test/java/org/olat/selenium/PortfolioTest.java +++ b/src/test/java/org/olat/selenium/PortfolioTest.java @@ -35,12 +35,10 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Assume; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.NavigationPage; -import org.olat.selenium.page.ScreenshotTestRule; import org.olat.selenium.page.course.CourseEditorPageFragment; import org.olat.selenium.page.course.CoursePageFragment; import org.olat.selenium.page.forum.ForumPage; @@ -48,8 +46,8 @@ import org.olat.selenium.page.graphene.OOGraphene; import org.olat.selenium.page.portfolio.ArtefactWizardPage; import org.olat.selenium.page.portfolio.PortfolioPage; import org.olat.selenium.page.repository.AuthoringEnvPage; -import org.olat.selenium.page.repository.FeedPage; import org.olat.selenium.page.repository.AuthoringEnvPage.ResourceType; +import org.olat.selenium.page.repository.FeedPage; import org.olat.selenium.page.user.UserToolsPage; import org.olat.selenium.page.wiki.WikiPage; import org.olat.test.ArquillianDeployments; @@ -78,8 +76,6 @@ public class PortfolioTest { private NavigationPage navBar; @Page private UserToolsPage userTools; - @Rule - public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule(); /** * Create a course with a forum, publish it. @@ -95,7 +91,6 @@ public class PortfolioTest { @RunAsClient public void collectForumArtefactInCourse(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -184,7 +179,6 @@ public class PortfolioTest { @RunAsClient public void collectWikiArtefactInWikiResource(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -266,7 +260,6 @@ public class PortfolioTest { @RunAsClient public void collectBlogPostInCourse(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -364,7 +357,6 @@ public class PortfolioTest { @RunAsClient public void addTextArtefact(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -431,7 +423,6 @@ public class PortfolioTest { @RunAsClient public void addTextArtefact_withinMap(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -497,7 +488,6 @@ public class PortfolioTest { @RunAsClient public void addLearningJournal(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -577,7 +567,6 @@ public class PortfolioTest { @RunAsClient public void addLearningJournal_withinMap(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage @@ -655,7 +644,6 @@ public class PortfolioTest { @RunAsClient public void addFileArtefact(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -731,8 +719,6 @@ public class PortfolioTest { @RunAsClient public void addFileArtefact_withinMap(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); - //File upload only work with Firefox Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -808,7 +794,6 @@ public class PortfolioTest { @RunAsClient public void createPortfolioTemplate_inCourse(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO author = new UserRestClient(deploymentUrl).createAuthor(); loginPage diff --git a/src/test/java/org/olat/selenium/UserTest.java b/src/test/java/org/olat/selenium/UserTest.java index 2bcd701231a2e7ff3329e78125a355c78b932cd3..06218f297d38ea908fb761554f7457174ddde5b5 100644 --- a/src/test/java/org/olat/selenium/UserTest.java +++ b/src/test/java/org/olat/selenium/UserTest.java @@ -35,13 +35,11 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Assume; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.olat.restapi.support.vo.CourseVO; import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.NavigationPage; -import org.olat.selenium.page.ScreenshotTestRule; import org.olat.selenium.page.Student; import org.olat.selenium.page.User; import org.olat.selenium.page.course.CoursePageFragment; @@ -85,8 +83,6 @@ public class UserTest { private UserToolsPage userTools; @Page private NavigationPage navBar; - @Rule - public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule(); /** * Set the resume preferences to automatically resume the session, @@ -198,7 +194,6 @@ public class UserTest { @RunAsClient public void resumeDisabled(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); loginPage @@ -240,7 +235,6 @@ public class UserTest { @RunAsClient public void userSwitchLanguageSwitchToEnglish(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); loginPage @@ -300,7 +294,6 @@ public class UserTest { @RunAsClient public void userChangeItsPassword(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); loginPage @@ -334,7 +327,6 @@ public class UserTest { @RunAsClient public void userResetItsPreferences(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); loginPage @@ -364,7 +356,6 @@ public class UserTest { @RunAsClient public void portletDeactivateActivate(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); loginPage @@ -400,7 +391,6 @@ public class UserTest { @RunAsClient public void movePortletToTheTop(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); loginPage @@ -442,7 +432,6 @@ public class UserTest { @RunAsClient public void browserBack(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser); Assume.assumeTrue(browser instanceof FirefoxDriver); @@ -479,7 +468,6 @@ public class UserTest { public void createUser(@InitialPage LoginPage loginPage, @Drone @User WebDriver userBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, userBrowser); //login loginPage @@ -526,7 +514,6 @@ public class UserTest { @RunAsClient public void deleteUser(@InitialPage LoginPage loginPage, @Drone @User WebDriver userBrowser) { - screenshotTestRule.setBrowsers(browser, userBrowser); //login loginPage @@ -588,8 +575,6 @@ public class UserTest { public void importUsers(@InitialPage LoginPage loginPage, @Drone @User WebDriver userBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, userBrowser); - //login loginPage .assertOnLoginPage() @@ -643,7 +628,6 @@ public class UserTest { @Drone @User WebDriver existingUserBrowser, @Drone @Student WebDriver newUserBrowser) throws IOException, URISyntaxException { - screenshotTestRule.setBrowsers(browser, existingUserBrowser, newUserBrowser); UserVO user1 = new UserRestClient(deploymentUrl) .createRandomUser("tsukune"); diff --git a/src/test/java/org/olat/selenium/page/ScreenshotTestRule.java b/src/test/java/org/olat/selenium/page/ScreenshotTestRule.java deleted file mode 100644 index adc4586ecca4e2745ffbd130864f1c5fe8957b5b..0000000000000000000000000000000000000000 --- a/src/test/java/org/olat/selenium/page/ScreenshotTestRule.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * <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.io.File; -import java.io.FileOutputStream; -import java.util.ArrayList; -import java.util.List; - -import org.junit.rules.MethodRule; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.openqa.selenium.OutputType; -import org.openqa.selenium.TakesScreenshot; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.remote.RemoteWebDriver; - -/** - * - * - * - * Initial date: 15.12.2015<br> - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - * - */ -public class ScreenshotTestRule implements MethodRule { - - private static final OLog log = Tracing.createLoggerFor(ScreenshotTestRule.class); - - private List<WebDriver> browserList; - - public void setBrowsers(WebDriver... browsers) { - browserList = new ArrayList<>(); - if(browsers != null && browsers.length > 0 && browsers[0] != null) { - for(WebDriver browser:browsers) { - if(browser != null) { - browserList.add(browser); - } - } - } - } - - - @Override - public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - try { - statement.evaluate(); - } catch (Throwable t) { - captureScreenshot(frameworkMethod.getName(), t); - throw t; // rethrow to allow the failure to be reported to JUnit - } - } - - private void captureScreenshot(String fileName, Throwable t) { - List<WebDriver> toShootList = new ArrayList<>(); - if(t instanceof WebDriverException) { - WebDriverException driverException = (WebDriverException)t; - String infos = driverException.getAdditionalInformation(); - for(WebDriver browser:browserList) { - if(browser instanceof RemoteWebDriver) { - try { - String sessionId = ((RemoteWebDriver)browser).getSessionId().toString(); - if(infos.contains(sessionId)) { - toShootList.add(browser); - } - } catch (IllegalStateException e) { - log.error("", e); - } - } - } - } - if(toShootList.isEmpty()) { - toShootList.addAll(browserList); - } - - int count = 0; - for(WebDriver browser:toShootList) { - if(browser instanceof TakesScreenshot) { - try { - new File("target/surefire-reports/").mkdirs(); // Insure directory is there - FileOutputStream out = new FileOutputStream("target/surefire-reports/screenshot-" + fileName + "_" + (count++)+ ".png"); - out.write(((TakesScreenshot) browser).getScreenshotAs(OutputType.BYTES)); - out.close(); - } catch (Exception e) { - log.error("", e); - } - } - } - } - }; - } -} \ No newline at end of file diff --git a/src/test/java/org/olat/selenium/page/course/CourseEditorPageFragment.java b/src/test/java/org/olat/selenium/page/course/CourseEditorPageFragment.java index 58dd5cf71212f082fa7720f27931cb26f754eba6..1727d57ca96083bae2464e7a210585b86faffe41 100644 --- a/src/test/java/org/olat/selenium/page/course/CourseEditorPageFragment.java +++ b/src/test/java/org/olat/selenium/page/course/CourseEditorPageFragment.java @@ -77,12 +77,13 @@ public class CourseEditorPageFragment { } public static CourseEditorPageFragment getEditor(WebDriver browser) { - OOGraphene.waitElement(editorBy, browser); + OOGraphene.waitElement(editorBy, 5, browser); OOGraphene.closeBlueMessageWindow(browser); return new CourseEditorPageFragment(browser); } public CourseEditorPageFragment assertOnEditor() { + OOGraphene.waitElement(editorBy, 5, browser); List<WebElement> editorEls = browser.findElements(editorBy); Assert.assertFalse(editorEls.isEmpty()); Assert.assertTrue(editorEls.get(0).isDisplayed()); 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 7e8372c487b9f6adda598a6b5d29c651a2020c86..c99911f6f6c3793da67a41842006e1b4346878f6 100644 --- a/src/test/java/org/olat/selenium/page/course/CoursePageFragment.java +++ b/src/test/java/org/olat/selenium/page/course/CoursePageFragment.java @@ -119,6 +119,25 @@ public class CoursePageFragment { return this; } + /** + * Wait until the restart button appears or make an error. + * + * @return + */ + public CoursePageFragment assertOnRestart() { + By restartBy = By.cssSelector("a.btn.o_sel_course_restart"); + OOGraphene.waitElement(restartBy, 10, browser); + return this; + } + + public CoursePageFragment clickRestart() { + By restartBy = By.cssSelector("a.btn.o_sel_course_restart"); + browser.findElement(restartBy).click(); + OOGraphene.waitBusy(browser); + OOGraphene.waitElement(courseRun, 5, browser); + return this; + } + /** * Click the first element of the menu tree * @return diff --git a/src/test/java/org/olat/selenium/page/course/MembersPage.java b/src/test/java/org/olat/selenium/page/course/MembersPage.java index f01f827fafb9dcfeec7e95c790743a4f198a46ac..428ebcf9fa3d49dddfc7e08c59b937974283fbf6 100644 --- a/src/test/java/org/olat/selenium/page/course/MembersPage.java +++ b/src/test/java/org/olat/selenium/page/course/MembersPage.java @@ -84,6 +84,8 @@ public class MembersPage { By createBy = By.className("o_sel_course_new_group"); browser.findElement(createBy).click(); OOGraphene.waitBusy(browser); + By popupBy = By.cssSelector("div.modal-content fieldset.o_sel_group_edit_group_form"); + OOGraphene.waitElement(popupBy, 5, browser); //fill the form By nameBy = By.cssSelector(".o_sel_group_edit_title input[type='text']"); diff --git a/src/test/java/org/olat/selenium/page/group/GroupsPage.java b/src/test/java/org/olat/selenium/page/group/GroupsPage.java index 40806cc168896ca45228d270ed8a11974efa3f23..8811d6cf8c2a8c477ef05423ea40318fbabddc63 100644 --- a/src/test/java/org/olat/selenium/page/group/GroupsPage.java +++ b/src/test/java/org/olat/selenium/page/group/GroupsPage.java @@ -61,6 +61,8 @@ public class GroupsPage { WebElement createButton = browser.findElement(createBy); createButton.click(); OOGraphene.waitBusy(browser); + By popupBy = By.cssSelector("div.modal-content fieldset.o_sel_group_edit_group_form"); + OOGraphene.waitElement(popupBy, 5, browser); //fill the form By nameBy = By.cssSelector(".o_sel_group_edit_title input[type='text']"); diff --git a/src/test/java/org/olat/selenium/page/user/UserAdminPage.java b/src/test/java/org/olat/selenium/page/user/UserAdminPage.java index 582b6889120b3d00af6e402ef76dda4ca0a0d98e..581e80c70c0301387cd14d301958c049451cfd45 100644 --- a/src/test/java/org/olat/selenium/page/user/UserAdminPage.java +++ b/src/test/java/org/olat/selenium/page/user/UserAdminPage.java @@ -83,6 +83,7 @@ public class UserAdminPage { */ public UserAdminPage searchUserToDelete(String username) { By createBy = By.cssSelector("fieldset.o_sel_user_search_form div.o_sel_user_search_username input[type='text']"); + OOGraphene.waitElement(createBy, 5, browser); browser.findElement(createBy).sendKeys(username); //search