diff --git a/src/main/java/org/olat/modules/webFeed/ui/blog/BlogPostFormController.java b/src/main/java/org/olat/modules/webFeed/ui/blog/BlogPostFormController.java index 435d3d79a010eb64d94c04340d3825633a0057c5..6f9f151032be8296478283d28d93871101184ade 100644 --- a/src/main/java/org/olat/modules/webFeed/ui/blog/BlogPostFormController.java +++ b/src/main/java/org/olat/modules/webFeed/ui/blog/BlogPostFormController.java @@ -163,6 +163,7 @@ public class BlogPostFormController extends FormBasicController { // Description description = uifactory.addRichTextElementForStringData("description", "feed.form.description", post.getDescription(), 8, -1, false, false, baseDir, null, formLayout, ureq.getUserSession(), getWindowControl()); + description.setElementCssClass("o_sel_blog_description"); RichTextConfiguration descRichTextConfig = description.getEditorConfiguration(); // set upload dir to the media dir descRichTextConfig.setFileBrowserUploadRelPath("media"); @@ -173,6 +174,7 @@ public class BlogPostFormController extends FormBasicController { // Content content = uifactory.addRichTextElementForStringData("content", "blog.form.content", post.getContent(), 18, -1, false, false, baseDir, null, formLayout, ureq.getUserSession(), getWindowControl()); + content.setElementCssClass("o_sel_blog_content"); RichTextConfiguration richTextConfig = content.getEditorConfiguration(); // set upload dir to the media dir richTextConfig.setFileBrowserUploadRelPath("media"); diff --git a/src/main/webapp/static/js/tinymce4/BTinyHelper.js b/src/main/webapp/static/js/tinymce4/BTinyHelper.js index 63e16dffa3ec2253892318d221b7930a494746f0..e7997af27a204bd1e9635966a52be7fc4f5c9272 100644 --- a/src/main/webapp/static/js/tinymce4/BTinyHelper.js +++ b/src/main/webapp/static/js/tinymce4/BTinyHelper.js @@ -139,7 +139,7 @@ var BTinyHelper = { // Remove the editor instance for the given DOM node ID if such an editor exists. // Remove all event handlers and release the memory removeEditorInstance : function (elementId) { - if (top.tinymce) { + if (top.tinymce && top.tinymce.editors) { var oldE = top.tinymce.get(elementId); if (oldE != null) { try { diff --git a/src/test/java/org/olat/login/FunctionalResumeTest.java b/src/test/java/org/olat/login/FunctionalResumeTest.java index e43f47d2d4c7ca7caddcd7d624dad6e7f18e81af..2647dcc5c4b513311231543bbe4fb15970a7d214 100644 --- a/src/test/java/org/olat/login/FunctionalResumeTest.java +++ b/src/test/java/org/olat/login/FunctionalResumeTest.java @@ -39,7 +39,6 @@ import org.olat.util.FunctionalCourseUtil; import org.olat.util.FunctionalHomeSiteUtil; import org.olat.util.FunctionalRepositorySiteUtil; import org.olat.util.FunctionalUtil; -import org.olat.util.FunctionalCourseUtil.AccessSettings; import org.olat.util.FunctionalUtil.OlatSite; import org.olat.util.FunctionalVOUtil; diff --git a/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java b/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java index 5f9df15f7a8219a8645a38a56edd01a388fe7175..c24e402b80560452f2ccd86e6b4f043e49379455 100644 --- a/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java +++ b/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java @@ -34,7 +34,6 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.olat.modules.fo.portfolio.ForumArtefact; @@ -52,11 +51,10 @@ import org.olat.user.restapi.UserVO; import org.olat.util.FunctionalCourseUtil; import org.olat.util.FunctionalEPortfolioUtil; import org.olat.util.FunctionalEPortfolioUtil.ArtefactAlias; -import org.olat.util.FunctionalUtil.WaitLimitAttribute; -import org.olat.util.FunctionalUtil.WaitForContentFlag; import org.olat.util.FunctionalHomeSiteUtil; import org.olat.util.FunctionalRepositorySiteUtil; import org.olat.util.FunctionalUtil; +import org.olat.util.FunctionalUtil.WaitLimitAttribute; import org.olat.util.FunctionalVOUtil; import com.thoughtworks.selenium.DefaultSelenium; diff --git a/src/test/java/org/olat/util/FunctionalCourseUtil.java b/src/test/java/org/olat/util/FunctionalCourseUtil.java index b5e84738f046f425440dc1526cdee1cb06d42649..644bca0b49aec81cdbfe5e639e8395826e295417 100644 --- a/src/test/java/org/olat/util/FunctionalCourseUtil.java +++ b/src/test/java/org/olat/util/FunctionalCourseUtil.java @@ -1036,31 +1036,22 @@ public class FunctionalCourseUtil { /* fill in short title */ functionalUtil.idle(browser); - - selectorBuffer = new StringBuffer(); - - selectorBuffer.append("xpath=(//div[contains(@class, 'o_editor')]//form//input[@type='text'])[1]"); - - browser.type(selectorBuffer.toString(), shortTitle); + String selShortTitle = "xpath=(//div[contains(@class, 'o_editor')]//form//input[@type='text'])[1]"; + browser.type(selShortTitle, shortTitle); /* fill in long title */ - selectorBuffer = new StringBuffer(); - - selectorBuffer.append("xpath=(//div[contains(@class, 'o_editor')]//form//input[@type='text'])[2]"); - - browser.type(selectorBuffer.toString(), longTitle); + String selLongtitle = "xpath=(//div[contains(@class, 'o_editor')]//form//input[@type='text'])[2]"; + browser.type(selLongtitle, longTitle); /* fill in description */ functionalUtil.typeMCE(browser, description); /* click save */ - selectorBuffer = new StringBuffer(); - - selectorBuffer.append("xpath=(//div[contains(@class, 'o_editor')]//form//button)[1]"); - browser.click(selectorBuffer.toString()); + String selSave = "xpath=(//div[contains(@class, 'o_editor')]//form//button[contains(@class, 'b_button')])[1]"; + browser.click(selSave); functionalUtil.waitForPageToLoad(browser); - return(true); + return true; } /** @@ -1184,13 +1175,13 @@ public class FunctionalCourseUtil { functionalUtil.typeMCE(browser, message); /* save form */ - selectorBuffer = new StringBuffer(); - selectorBuffer.append("xpath=//div[contains(@class, '") - .append(getCourseRunCss()) - .append("')]//form//button[last()]"); + StringBuilder selSave = new StringBuilder(); + selSave.append("xpath=//div[contains(@class, '") + .append(getCourseRunCss()) + .append("')]//form//button[last()][contains(@class,'b_button')]"); - browser.click(selectorBuffer.toString()); + browser.click(selSave.toString()); functionalUtil.waitForPageToLoad(browser); @@ -1520,12 +1511,12 @@ public class FunctionalCourseUtil { /* fill in form - description */ if(edit == null || ArrayUtils.contains(edit, BlogEdit.DESCRIPTION)){ - functionalUtil.typeMCE(browser, getBlogFormCss(), 0, description); + functionalUtil.typeMCE(browser, "o_sel_blog_description", description); } /* fill in form - content */ if(edit == null || ArrayUtils.contains(edit, BlogEdit.CONTENT)){ - functionalUtil.typeMCE(browser, getBlogFormCss(), 1, content); + functionalUtil.typeMCE(browser, "o_sel_blog_content", content); } /* save form */ diff --git a/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java b/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java index b4d962cb598cfcd66cdf9288c187a21caab874f0..8b525d79040001d9cf19e04be9c677e23f36e42b 100644 --- a/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java +++ b/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java @@ -843,7 +843,7 @@ public class FunctionalEPortfolioUtil { browser.type(selectorBuffer.toString(), title); /* description */ - functionalUtil.typeMCE(browser, getEPortfolioMapCss(), 0, description); + functionalUtil.typeMCE(browser, getEPortfolioMapCss(), description); /* save */ selectorBuffer = new StringBuffer(); diff --git a/src/test/java/org/olat/util/FunctionalUtil.java b/src/test/java/org/olat/util/FunctionalUtil.java index 7695e34dd82d866902f5c61bc2499d239a78bb0f..953580c072d065f47fe1e8c16dc429448f340012 100644 --- a/src/test/java/org/olat/util/FunctionalUtil.java +++ b/src/test/java/org/olat/util/FunctionalUtil.java @@ -440,6 +440,10 @@ public class FunctionalUtil { return(false); } + public boolean waitForPageToLoadContent(Selenium browser, String iframeSelectors, String content, WaitLimitAttribute wait, boolean throwException){ + return(waitForPageToLoadContent(browser, new String[]{ iframeSelectors }, content, wait, new WaitForContentFlag[]{WaitForContentFlag.EQUALS, WaitForContentFlag.STRIP_TAGS}, throwException)); + } + /** * * @param browser @@ -464,7 +468,9 @@ public class FunctionalUtil { /* traverse iframes */ if(iframeSelectors != null){ - for(int i=0; i < iframeSelectors.length;i++) browser.selectFrame(iframeSelectors[i]); + for(int i=0; i < iframeSelectors.length;i++) { + browser.selectFrame(iframeSelectors[i]); + } } do{ @@ -474,9 +480,11 @@ public class FunctionalUtil { source = functionalHtmlUtil.stripTags(source, true); } + boolean useEquals = (flags != null && ArrayUtils.contains(flags, WaitForContentFlag.EQUALS)); + if((content == null && source == null) || - (flags != null && content != null && ArrayUtils.contains(flags, WaitForContentFlag.EQUALS) && content.equals(source)) || - (source != null && !ArrayUtils.contains(flags, WaitForContentFlag.EQUALS) && source.contains(content))){ + (useEquals && content != null && source != null && content.trim().equals(source.trim())) || + (source != null && content != null && !ArrayUtils.contains(flags, WaitForContentFlag.EQUALS) && source.trim().contains(content.trim()))) { log.info("found content after " + (currentTime - startTime) + "ms"); /* go back to toplevel */ @@ -484,7 +492,7 @@ public class FunctionalUtil { browser.selectFrame("relative=top"); } - return(true); + return true; } try { @@ -505,8 +513,7 @@ public class FunctionalUtil { if(throwException){ throw new SeleniumException("timed out after " + waitLimit + "ms"); } - - return(false); + return false; } /** @@ -1205,33 +1212,19 @@ public class FunctionalUtil { * @param content * @return */ - public boolean typeMCE(Selenium browser, String content){ - if(content == null) - return(true); + public void typeMCE(Selenium browser, String content){ + if(content == null)return; idle(browser); - StringBuffer selectorBuffer = new StringBuffer(); - - selectorBuffer.append("dom=document.getElementsByClassName('") - .append("mceIframeContainer") - .append("')[0].getElementsByTagName('iframe')[0].contentDocument.body"); - - waitForPageToLoadElement(browser, selectorBuffer.toString()); - - browser.type(selectorBuffer.toString(), content); - - waitForPageToLoadContent(browser, - new String[]{"dom=document.getElementsByClassName('mceIframeContainer')[0].getElementsByTagName('iframe')[0]"}, - functionalHtmlUtil.stripTags(content, true), DEFAULT_WAIT_LIMIT, true); - - return(true); - } - - public boolean typeMCE(Selenium browser, String cssClass, String content){ - return(typeMCE(browser, cssClass, 0, content)); + String iframeSelector = "dom=document.getElementsByClassName('mce-edit-area')[0].getElementsByTagName('iframe')[0]"; + + browser.runScript("top.tinymce.activeEditor.setContent('" + content + "')"); + + String strippedContent = functionalHtmlUtil.stripTags(content, true); + waitForPageToLoadContent(browser, iframeSelector, strippedContent, DEFAULT_WAIT_LIMIT, true); } - + /** * * @param browser @@ -1239,35 +1232,37 @@ public class FunctionalUtil { * @param content * @return */ - public boolean typeMCE(Selenium browser, String cssClass, int nth, String content){ - if(content == null) - return(true); - + public void typeMCE(Selenium browser, String cssClass, String content) { + if(content == null) return; + idle(browser); - StringBuffer iframeSelectorBuffer = new StringBuffer(); - + //wait tiny + StringBuilder iframeSelectorBuffer = new StringBuilder(); iframeSelectorBuffer.append("dom=document.getElementsByClassName('") - .append(cssClass) - .append("')[0].getElementsByClassName('") - .append("mceIframeContainer") - .append("')[") - .append(nth) - .append("].getElementsByTagName('iframe')[0]"); - - StringBuffer selectorBuffer = new StringBuffer(iframeSelectorBuffer); + .append(cssClass) + .append("')[0].getElementsByClassName('mce-edit-area')[0].getElementsByTagName('iframe')[0]"); + StringBuilder selectorBuffer = new StringBuilder(iframeSelectorBuffer); selectorBuffer.append(".contentDocument.body"); - waitForPageToLoadElement(browser, selectorBuffer.toString()); - browser.type(selectorBuffer.toString(), content); - - waitForPageToLoadContent(browser, - new String[]{iframeSelectorBuffer.toString()}, - functionalHtmlUtil.stripTags(content, true), DEFAULT_WAIT_LIMIT, true); - - return(true); + //write in tiny + try { + String selIframe = "//div[contains(@class,'" + cssClass + "')]//div[contains(@class,'mce-tinymce')]//iframe"; + String iframeId = browser.getAttribute("" + selIframe + "@id"); + int index = iframeId.lastIndexOf('_'); + String editorId = iframeId.substring(0, index); + content = content.replace("\n", "<br/>"); + browser.runScript("top.tinymce.editors['" + editorId + "'].setContent('" + content + "')"); + } catch (Exception e) { + e.printStackTrace(); + } + + //wait until it's done + String strippedContent = functionalHtmlUtil.stripTags(content, true); + waitForPageToLoadContent(browser, iframeSelectorBuffer.toString(), + strippedContent, DEFAULT_WAIT_LIMIT, true); } /**