From b5d173638d088f7442d36d796413a240000906bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Kr=C3=A4hemann?= <joel.kraehemann@frentix.com> Date: Tue, 16 Oct 2012 12:22:33 +0200 Subject: [PATCH] OO-296, OO-306: replaced obsolete code within addToEPorfolio(). --- .../org/olat/util/FunctionalCourseUtil.java | 14 +-- .../olat/util/FunctionalEPortfolioUtil.java | 109 +++++++++++------- 2 files changed, 71 insertions(+), 52 deletions(-) diff --git a/src/test/java/org/olat/util/FunctionalCourseUtil.java b/src/test/java/org/olat/util/FunctionalCourseUtil.java index 2be6cdc2315..11a0beb58af 100644 --- a/src/test/java/org/olat/util/FunctionalCourseUtil.java +++ b/src/test/java/org/olat/util/FunctionalCourseUtil.java @@ -918,19 +918,7 @@ public class FunctionalCourseUtil { functionalEPortfolioUtil.fillInTags(browser, tags); /* fill in wizard - destination */ - String selector = functionalEPortfolioUtil.createSelector(binder, page, structure); - - functionalUtil.waitForPageToLoadElement(browser, selector); - - browser.click(selector); - - selectorBuffer = new StringBuffer(); - - selectorBuffer.append("xpath=//li[contains(@class, 'x-tree-node')]//a//span[contains(text(), '") - .append((structure != null) ? structure: page) - .append("')]"); - - functionalUtil.waitForPageToLoadElement(browser, selectorBuffer.toString()); + functionalEPortfolioUtil.selectTree(browser, binder, page, structure); } /* click finish */ diff --git a/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java b/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java index 99454273ee9..bcb42aff473 100644 --- a/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java +++ b/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java @@ -586,6 +586,8 @@ public class FunctionalEPortfolioUtil { functionalUtil.waitForPageToLoad(browser); + boolean modified = false; + /* fill in wizard - title */ if(title != null){ selectorBuffer = new StringBuffer(); @@ -596,6 +598,8 @@ public class FunctionalEPortfolioUtil { functionalUtil.waitForPageToLoadElement(browser, selectorBuffer.toString()); browser.type(selectorBuffer.toString(), title); + + modified = true; } /* fill in wizard - display */ @@ -610,24 +614,32 @@ public class FunctionalEPortfolioUtil { functionalUtil.waitForPageToLoadElement(browser, selectorBuffer.toString()); browser.click(selectorBuffer.toString()); + + modified = true; } /* fill in wizard - description */ - functionalUtil.typeMCE(browser, description); + if(description != null){ + functionalUtil.typeMCE(browser, description); + + modified = true; + } /* fill in wizard - save */ - selectorBuffer = new StringBuffer(); + if(modified){ + selectorBuffer = new StringBuffer(); - selectorBuffer.append("xpath=//div[contains(@class, '") - .append(getEPortfolioMapCss()) - .append("')]//form//button[last() and contains(@class, '") - .append(functionalUtil.getButtonDirtyCss()) - .append("')]"); - - functionalUtil.waitForPageToLoadElement(browser, selectorBuffer.toString()); - browser.click(selectorBuffer.toString()); - - functionalUtil.waitForPageToLoad(browser); + selectorBuffer.append("xpath=//div[contains(@class, '") + .append(getEPortfolioMapCss()) + .append("')]//form//button[last() and contains(@class, '") + .append(functionalUtil.getButtonDirtyCss()) + .append("')]"); + + functionalUtil.waitForPageToLoadElement(browser, selectorBuffer.toString()); + browser.click(selectorBuffer.toString()); + + functionalUtil.waitForPageToLoad(browser); + } return(true); } @@ -641,6 +653,15 @@ public class FunctionalEPortfolioUtil { * @return */ public boolean renamePage(Selenium browser, String binder, String oldName, String newName){ + /* wait until tree has loaded */ + StringBuffer locatorBuffer = new StringBuffer(); + + locatorBuffer.append("xpath=//li[contains(@class, '") + .append(functionalUtil.getTreeNodeLoadingCss()) + .append("')]"); + functionalUtil.waitForPageToUnloadElement(browser, locatorBuffer.toString()); + + /* select page */ String selector = createSelector(binder, oldName, null); functionalUtil.waitForPageToLoadElement(browser, selector); @@ -826,6 +847,7 @@ public class FunctionalEPortfolioUtil { functionalUtil.waitForPageToLoadElement(browser, selectorBuffer.toString()); browser.click(selectorBuffer.toString()); + /* */ functionalUtil.waitForPageToLoadElement(browser, createSelector(binder, page, title)); return(true); @@ -1006,33 +1028,6 @@ public class FunctionalEPortfolioUtil { return(fillInTags(browser, tags, true)); } - protected boolean selectTree(Selenium browser, String binder, String page, String structure){ - String selector = createSelector(binder, page, structure); - - /* wait until tree has loaded */ - StringBuffer locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//li[contains(@class, '") - .append(functionalUtil.getTreeNodeLoadingCss()) - .append("')]"); - functionalUtil.waitForPageToUnloadElement(browser, locatorBuffer.toString()); - - /* click selector */ - functionalUtil.waitForPageToLoadElement(browser, selector); - - browser.click(selector); - - locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//li[contains(@class, 'x-tree-node')]//a//span[contains(text(), '") - .append((structure != null) ? structure: page) - .append("')]"); - - functionalUtil.waitForPageToLoadElement(browser, locatorBuffer.toString()); - - return(true); - } - /** * Fills in the open wizard's tags. * @@ -1080,6 +1075,42 @@ public class FunctionalEPortfolioUtil { return(true); } + /** + * Selects a tree node. + * + * @param browser + * @param binder + * @param page + * @param structure + * @return + */ + protected boolean selectTree(Selenium browser, String binder, String page, String structure){ + String selector = createSelector(binder, page, structure); + + /* wait until tree has loaded */ + StringBuffer locatorBuffer = new StringBuffer(); + + locatorBuffer.append("xpath=//li[contains(@class, '") + .append(functionalUtil.getTreeNodeLoadingCss()) + .append("')]"); + functionalUtil.waitForPageToUnloadElement(browser, locatorBuffer.toString()); + + /* click selector */ + functionalUtil.waitForPageToLoadElement(browser, selector); + + browser.click(selector); + + locatorBuffer = new StringBuffer(); + + locatorBuffer.append("xpath=//li[contains(@class, 'x-tree-node')]//a//span[contains(text(), '") + .append((structure != null) ? structure: page) + .append("')]"); + + functionalUtil.waitForPageToLoadElement(browser, locatorBuffer.toString()); + + return(true); + } + /** * * @param browser -- GitLab