Skip to content
Snippets Groups Projects
Commit 8eacd70d authored by srosse's avatar srosse
Browse files

OO-4454: update selenium tests with catalog

parent 8d16c56e
No related branches found
No related tags found
No related merge requests found
...@@ -1435,10 +1435,11 @@ public class CourseElementTest extends Deployments { ...@@ -1435,10 +1435,11 @@ public class CourseElementTest extends Deployments {
.resume(); .resume();
String node1 = "Forums " + UUID.randomUUID(); String node1 = "Forums " + UUID.randomUUID();
String node1Short = "Forum " + JunitTestHelper.miniRandom();
NavigationPage navBar = NavigationPage.load(browser); NavigationPage navBar = NavigationPage.load(browser);
navBar navBar
.openCatalogAdministration() .openCatalogAdministration()
.addCatalogNode(node1, "First level of the catalog", "First level of the catalog"); .addCatalogNode(node1, node1Short, "First level of the catalog");
//create a course //create a course
String courseTitle = "Guest FO " + UUID.randomUUID(); String courseTitle = "Guest FO " + UUID.randomUUID();
...@@ -1481,7 +1482,7 @@ public class CourseElementTest extends Deployments { ...@@ -1481,7 +1482,7 @@ public class CourseElementTest extends Deployments {
NavigationPage guestNavBar = NavigationPage.load(guestBrowser); NavigationPage guestNavBar = NavigationPage.load(guestBrowser);
guestNavBar guestNavBar
.openCatalog() .openCatalog()
.selectCatalogEntry(node1) .selectCatalogEntry(node1, node1Short)
.select(courseTitle) .select(courseTitle)
.start(); .start();
......
...@@ -544,6 +544,7 @@ public class CourseTest extends Deployments { ...@@ -544,6 +544,7 @@ public class CourseTest extends Deployments {
.assertOnTitle(newCourseName); .assertOnTitle(newCourseName);
} }
/** /**
* *
* Create a catalog, create a course, while publishing add the * Create a catalog, create a course, while publishing add the
...@@ -560,7 +561,7 @@ public class CourseTest extends Deployments { ...@@ -560,7 +561,7 @@ public class CourseTest extends Deployments {
@Drone @User WebDriver userBrowser) @Drone @User WebDriver userBrowser)
throws IOException, URISyntaxException { throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor(); UserVO author = new UserRestClient(deploymentUrl).createRandomAuthor();
UserVO user = new UserRestClient(deploymentUrl).createRandomUser(); UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
//administrator create the categories in the catalog //administrator create the categories in the catalog
...@@ -573,12 +574,15 @@ public class CourseTest extends Deployments { ...@@ -573,12 +574,15 @@ public class CourseTest extends Deployments {
String node1 = "First level " + UUID.randomUUID(); String node1 = "First level " + UUID.randomUUID();
String node2_1 = "Second level first element " + UUID.randomUUID(); String node2_1 = "Second level first element " + UUID.randomUUID();
String node2_2 = "Second level second element " + UUID.randomUUID(); String node2_2 = "Second level second element " + UUID.randomUUID();
String node1Short = "First " + JunitTestHelper.miniRandom();
String node2_1Short = "1.1l " + JunitTestHelper.miniRandom();
String node2_2Short = "1.2l " + JunitTestHelper.miniRandom();
adminNavBar adminNavBar
.openCatalogAdministration() .openCatalogAdministration()
.addCatalogNode(node1, "First level of the catalog", "First level of the catalog") .addCatalogNode(node1, node1Short, "First level of the catalog")
.selectNode(node1) .selectNode(node1Short)
.addCatalogNode(node2_1, "First element of the second level", "First element of the second level") .addCatalogNode(node2_1, node2_1Short, "First element of the second level")
.addCatalogNode(node2_2, "Second element of the second level", "Second element of the second level"); .addCatalogNode(node2_2, node2_2Short, "Second element of the second level");
//An author create a course and publish it under a category //An author create a course and publish it under a category
//created above //created above
...@@ -616,8 +620,8 @@ public class CourseTest extends Deployments { ...@@ -616,8 +620,8 @@ public class CourseTest extends Deployments {
userNavBar userNavBar
.openMyCourses() .openMyCourses()
.openCatalog() .openCatalog()
.selectCatalogEntry(node1) .selectCatalogEntry(node1Short)
.selectCatalogEntry(node2_2) .selectCatalogEntry(node2_2Short)
.select(courseTitle)//go to the details page .select(courseTitle)//go to the details page
.start(); .start();
......
...@@ -125,8 +125,9 @@ public class MyCoursesPage { ...@@ -125,8 +125,9 @@ public class MyCoursesPage {
OOGraphene.waitBusy(browser); OOGraphene.waitBusy(browser);
} }
public MyCoursesPage selectCatalogEntry(String title) { public MyCoursesPage selectCatalogEntry(String shortTitle) {
By titleBy = By.xpath("//div[contains(@class,'o_sublevel')]//div[contains(@class,'o_meta')]//h4[contains(@class,'o_title')]/a/span[text()[contains(.,'" + title + "')]]"); By titleBy = By.xpath("//div[contains(@class,'o_sublevel')][div[contains(@class,'o_meta')]/h4[@class='o_title'][contains(.,'" + shortTitle + "')]]/div/a");
OOGraphene.waitElement(titleBy, browser);
List<WebElement> titleLinks = browser.findElements(titleBy); List<WebElement> titleLinks = browser.findElements(titleBy);
Assert.assertEquals(1, titleLinks.size()); Assert.assertEquals(1, titleLinks.size());
titleLinks.get(0).click(); titleLinks.get(0).click();
......
...@@ -19,13 +19,9 @@ ...@@ -19,13 +19,9 @@
*/ */
package org.olat.selenium.page.repository; package org.olat.selenium.page.repository;
import java.util.List;
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.WebDriver;
import org.openqa.selenium.WebElement;
/** /**
* Drives the catalog administration * Drives the catalog administration
...@@ -59,10 +55,8 @@ public class CatalogAdminPage { ...@@ -59,10 +55,8 @@ public class CatalogAdminPage {
By titleBy = By.cssSelector(".o_sel_catalog_add_category_popup .o_sel_cat_name input[type='text']"); By titleBy = By.cssSelector(".o_sel_catalog_add_category_popup .o_sel_cat_name input[type='text']");
OOGraphene.waitElement(titleBy, browser); OOGraphene.waitElement(titleBy, browser);
browser.findElement(titleBy).sendKeys(title); browser.findElement(titleBy).sendKeys(title);
/*
By shortTitleBy = By.cssSelector(".o_sel_catalog_add_category_popup .o_sel_cat_short_title input[type='text']"); By shortTitleBy = By.cssSelector(".o_sel_catalog_add_category_popup .o_sel_cat_short_title input[type='text']");
browser.findElement(shortTitleBy).sendKeys(shortTitle); browser.findElement(shortTitleBy).sendKeys(shortTitle);
*/
OOGraphene.tinymce(description, browser); OOGraphene.tinymce(description, browser);
...@@ -70,7 +64,7 @@ public class CatalogAdminPage { ...@@ -70,7 +64,7 @@ public class CatalogAdminPage {
By saveBy = By.cssSelector(".o_sel_catalog_add_category_popup .o_sel_catalog_entry_form_buttons button.btn-primary"); By saveBy = By.cssSelector(".o_sel_catalog_add_category_popup .o_sel_catalog_entry_form_buttons button.btn-primary");
browser.findElement(saveBy).click(); browser.findElement(saveBy).click();
OOGraphene.waitBusy(browser); OOGraphene.waitBusy(browser);
By nodeTitleBy = By.xpath("//div[contains(@class,'o_meta')]//h4[contains(@class,'o_title')]//a/span[contains(text(),'" + title + "')]"); By nodeTitleBy = By.xpath("//div[contains(@class,'o_meta')]//h4[contains(@class,'o_title')][contains(text(),'" + shortTitle + "')]");
OOGraphene.waitElement(nodeTitleBy, browser); OOGraphene.waitElement(nodeTitleBy, browser);
return this; return this;
} }
...@@ -81,11 +75,10 @@ public class CatalogAdminPage { ...@@ -81,11 +75,10 @@ public class CatalogAdminPage {
* @param title * @param title
* @return * @return
*/ */
public CatalogAdminPage selectNode(String title) { public CatalogAdminPage selectNode(String shortTitle) {
By titleBy = By.xpath("//div[contains(@class,'o_meta')]//h4[contains(@class,'o_title')]/a/span[text()[contains(.,'" + title + "')]]"); By titleBy = By.xpath("//div[contains(@class,'o_sublevel')][div[contains(@class,'o_meta')]//h4[contains(@class,'o_title')][text()[contains(.,'" + shortTitle + "')]]]/div/a");
List<WebElement> nodeLinks = browser.findElements(titleBy); OOGraphene.waitElement(titleBy, browser);
Assert.assertEquals(1, nodeLinks.size()); browser.findElements(titleBy).get(0).click();
nodeLinks.get(0).click();
OOGraphene.waitBusy(browser); OOGraphene.waitBusy(browser);
return this; return this;
} }
......
...@@ -42,15 +42,15 @@ public class CatalogPage { ...@@ -42,15 +42,15 @@ public class CatalogPage {
this.browser = browser; this.browser = browser;
} }
public CatalogPage selectCatalogEntry(String title) { public CatalogPage selectCatalogEntry(String title, String shortTitle) {
By titleBy = By.xpath("//div[contains(@class,'o_sublevel')]//h4[contains(@class,'o_title')]/a/span[text()[contains(.,'" + title + "')]]"); By titleBy = By.xpath("//div[contains(@class,'o_sublevel')][div/h4[contains(@class,'o_title')][text()[contains(.,'" + shortTitle + "')]]]/div/a");
List<WebElement> titleLinks = browser.findElements(titleBy); List<WebElement> titleLinks = browser.findElements(titleBy);
Assert.assertFalse(titleLinks.isEmpty()); Assert.assertFalse(titleLinks.isEmpty());
titleLinks.get(0).click(); titleLinks.get(0).click();
OOGraphene.waitBusy(browser); OOGraphene.waitBusy(browser);
By pageTitleBy = By.xpath("//h2[text()[contains(.,'" + title + "')]]"); By pageTitleBy = By.xpath("//h2[text()[contains(.,'" + title + "')]]");
OOGraphene.waitElement(pageTitleBy, 5, browser); OOGraphene.waitElement(pageTitleBy, browser);
return this; return this;
} }
......
...@@ -93,6 +93,17 @@ public class JunitTestHelper { ...@@ -93,6 +93,17 @@ public class JunitTestHelper {
return UUID.randomUUID().toString(); return UUID.randomUUID().toString();
} }
/**
* This method returns the first bloc of a UUID. It's
* not really random. But it's only 7 characters long.
*
* @return The first bloc of a UUID
*/
public static final String miniRandom() {
String r = UUID.randomUUID().toString();
return r.substring(0, r.indexOf('-'));
}
public static final OLATResource createRandomResource() { public static final OLATResource createRandomResource() {
String resName = UUID.randomUUID().toString().replace("-", ""); String resName = UUID.randomUUID().toString().replace("-", "");
long resId = randomResId.nextInt(Integer.MAX_VALUE - 10) + 1; long resId = randomResId.nextInt(Integer.MAX_VALUE - 10) + 1;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<property name="dimensions">1024x800</property> <property name="dimensions">1024x800</property>
<!-- <!--
<property name="downloadBinaries">no</property> <property name="downloadBinaries">no</property>
<property name="chromeDriverBinary">target/drone/57d2a9629298aa6dc2d759fe09da5d13/chromedriver</property> <property name="chromeDriverBinary">target/drone/675a673c111fdcc9678d11df0e69b334/chromedriver</property>
<property name="firefoxDriverBinary">target/drone/ce03addb1fc8c24900011f90fc80f3c1/geckodriver</property> <property name="firefoxDriverBinary">target/drone/ce03addb1fc8c24900011f90fc80f3c1/geckodriver</property>
--> -->
<property name="firefoxUserPreferences">src/test/profile/firefox/prefs.js</property> <property name="firefoxUserPreferences">src/test/profile/firefox/prefs.js</property>
......
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