Author: jjamrich
Date: 2011-08-08 18:53:02 -0400 (Mon, 08 Aug 2011)
New Revision: 22607
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java
Log:
Updated test for readonly and toolbar editor's attributes.
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java 2011-08-08
22:52:43 UTC (rev 22606)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java 2011-08-08
22:53:02 UTC (rev 22607)
@@ -4,7 +4,6 @@
package org.richfaces.tests.metamer.ftest.richEditor;
import static java.text.MessageFormat.format;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -16,10 +15,8 @@
import org.jboss.test.selenium.encapsulated.FrameLocator;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.utils.URLUtils;
-import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.slf4j.Logger;
@@ -46,10 +43,8 @@
private JQueryLocator a4jSubmit = pjq("input[id$=a4jButton]");
private JQueryLocator validationMsgLoc = pjq("span.rf-msgs-sum");
- private JQueryLocator editorToolbarGroup = jq("span.cke_toolgroup");
+ private JQueryLocator editorToolbarGroup = jq("span.cke_toolbar");
- private JQueryLocator editorToolbarContainer = jq("td.cke_toolgroup");
-
private Attribute styleAttribute = new Attribute("style");
public enum toolbarGroup {
@@ -133,6 +128,23 @@
selenium.selectFrame(FrameLocator.PARENT);
}
+ /**
+ * Method for retrieve text from editor.
+ * Editor lives within iFrame, so there are need some additional steps
+ * to reach element containing editor text
+ * @return
+ */
+ private String getEditorText(){
+ selenium.selectFrame(frameLocator);
+
+ String currentText = selenium.getText(editorArea);
+
+ // focus back to main window - parent of iframe
+ selenium.selectFrame(FrameLocator.PARENT);
+
+ return currentText;
+ }
+
@Test
public void testValueChangeListener(){
verifyValueChangeListener(hSubmit);
@@ -199,14 +211,17 @@
public void testReadonly() {
typeTextToEditor(text1);
- assertTrue(text1.contains(selenium.getText(editorTextArea)));
+ String currentText = getEditorText();
+ assertTrue(currentText != null && currentText.contains(text1));
+
attributes.setReadonly(Boolean.TRUE);
// waitModel.until(elementPresent.locator(editor));
typeTextToEditor("test");
// assert that there is no "test" present in editor text area
- assertFalse(text1.contains(selenium.getText(editorTextArea)));
+ currentText = getEditorText();
+ assertFalse(currentText != null &&
currentText.contains("test"));
// now set read-only back to false
attributes.setReadonly(Boolean.FALSE);
@@ -216,7 +231,8 @@
typeTextToEditor(text2);
// now we should assert that only expected text are present
- assertTrue(text2.contains(selenium.getText(editorTextArea)));
+ currentText = getEditorText();
+ assertTrue(currentText != null && currentText.contains(text2));
}
@Test
Show replies by date