Author: vmassol
Date: 2010-06-28 15:36:43 +0200 (Mon, 28 Jun 2010)
New Revision: 29788
Added:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditObjectsTest.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ClassEditPage.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/DatabaseListClassEditElement.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ObjectEditPage.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/PreviewableEditPage.java
Removed:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditObjectsPage.java
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditWikiTest.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/BasePage.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditPage.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/FormElement.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ViewPage.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WYSIWYGEditPage.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WikiEditPage.java
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/invitation/InvitationTest.java
Log:
Start porting the XObjectsTest class to the XWiki selenium2 framework
Added:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditObjectsTest.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditObjectsTest.java
(rev 0)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditObjectsTest.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -0,0 +1,91 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.it.ui;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.xwiki.it.ui.framework.AbstractAdminAuthenticatedTest;
+import org.xwiki.it.ui.framework.elements.ClassEditPage;
+import org.xwiki.it.ui.framework.elements.FormElement;
+import org.xwiki.it.ui.framework.elements.ObjectEditPage;
+import org.xwiki.it.ui.framework.elements.ViewPage;
+import org.xwiki.it.ui.framework.elements.WikiEditPage;
+
+/**
+ * Test XObject editing.
+ *
+ * @version $Id$
+ * @since 2.4M2
+ */
+public class EditObjectsTest extends AbstractAdminAuthenticatedTest
+{
+ @Before
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+ getUtil().deletePage("Test", "EditObjectsTestClass");
+ getUtil().deletePage("Test", "EditObjectsTestObject");
+ }
+
+ /**
+ * Tests that XWIKI-1621 remains fixed.
+ */
+ @Test
+ public void testChangeMultiselectProperty()
+ {
+ // Create a class with a database list property set to return all documents
+ ClassEditPage cep = new ClassEditPage();
+ cep.switchToEdit("Test", "EditObjectsTestClass");
+ cep.addProperty("prop",
"com.xpn.xwiki.objects.classes.DBListClass");
+ cep.getDatabaseListClassEditElement("prop").setHibernateQuery(
+ "select doc.fullName from XWikiDocument doc where doc.space =
'Test'");
+ ViewPage vp = cep.clickSaveAndView();
+
+ // Create a second page to hold the Object and set its content
+ WikiEditPage wep = new WikiEditPage();
+ wep.switchToEdit("Test", "EditObjectsTestObject");
+ wep.setContent("this is the content");
+ vp = wep.clickSaveAndView();
+
+ // Add an object of the class created and set the value to be the test page
+ ObjectEditPage oep = vp.clickEditObjects();
+ FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
+ objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"),
"Test.EditObjectsTestClass");
+ vp = oep.clickSaveAndView();
+
+ // Set multiselect to true
+ cep = new ClassEditPage();
+ cep.switchToEdit("Test", "EditObjectsTestClass");
+ cep.getDatabaseListClassEditElement("prop").isMultiSelect(true);
+ vp = cep.clickSaveAndView();
+
+ // Select a second document in the DB list select field.
+ oep = new ObjectEditPage();
+ oep.switchToEdit("Test", "EditObjectsTestObject");
+
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(
+ By.id("Test.EditObjectsTestClass_0_prop"),
"Test.EditObjectsTestObject");
+ vp = oep.clickSaveAndView();
+
+ Assert.assertEquals("this is the content", vp.getContent());
+ }
+}
Property changes on:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditObjectsTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Id Revision HeadURL
Name: svn:eol-style
+ native
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditWikiTest.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditWikiTest.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/EditWikiTest.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -35,7 +35,7 @@
*/
public class EditWikiTest extends AbstractAdminAuthenticatedTest
{
- /** Page used for testing: Main.EditWikiTest */
+ /** Page used for testing: Test.EditWikiTest */
private WikiEditPage editPage;
@Before
@@ -47,12 +47,6 @@
getUtil().deletePage("Test", "EditWikiTest");
}
- @After
- public void cleanUp()
- {
- getUtil().deletePage("Test", "EditWikiTest");
- }
-
/** Test that save and continue saves as a minor version. */
@Test
public void testSaveAndContinueSavesAsMinorEdit()
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/BasePage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/BasePage.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/BasePage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -179,16 +179,18 @@
/**
* Performs a click on the "edit objects" entry of the content menu.
*/
- public void clickEditObjects()
+ public ObjectEditPage clickEditObjects()
{
- clickContentMenuEditSubMenuEntry("tmEditObjects");
+ clickContentMenuEditSubMenuEntry("tmEditObject");
+ return new ObjectEditPage();
}
/**
* Performs a click on the "edit class" entry of the content menu.
*/
- public void clickEditClass()
+ public ClassEditPage clickEditClass()
{
clickContentMenuEditSubMenuEntry("tmEditClass");
+ return new ClassEditPage();
}
}
Added:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ClassEditPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ClassEditPage.java
(rev 0)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ClassEditPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -0,0 +1,112 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.it.ui.framework.elements;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+/**
+ * Represents the common actions possible on all Pages when using the "edit"
action with the "class" editor.
+ *
+ * @version $Id$
+ * @since 2.4M2
+ */
+// TODO: Fix the fact that this class should extend EditPage but the id of the save
action is incorrectly different...
+public class ClassEditPage extends BasePage
+{
+ @FindBy(name = "action_saveandcontinue")
+ private WebElement saveandcontinue;
+
+ @FindBy(name = "action_propupdate")
+ private WebElement saveandview;
+
+ @FindBy(name = "action_cancel")
+ private WebElement cancel;
+
+ @FindBy(id ="propupdate")
+ private WebElement propertyForm;
+
+ @FindBy(id = "propname")
+ private WebElement propertyNameField;
+
+ @FindBy(id = "proptype")
+ private WebElement propertyTypeField;
+
+ @FindBy(name = "action_propadd")
+ private WebElement propertySubmit;
+
+ private FormElement form;
+
+ public void addProperty(String propertyName, String propertyType)
+ {
+ getForm().setFieldValue(this.propertyNameField, propertyName);
+ getForm().setFieldValue(this.propertyTypeField, propertyType);
+ this.propertySubmit.click();
+ }
+
+ private FormElement getForm()
+ {
+ if (this.form == null) {
+ this.form = new FormElement(this.propertyForm);
+ }
+ return this.form;
+ }
+
+ /**
+ * Start editing the page using the Class editor.
+ *
+ * @param space
+ * @param page
+ */
+ public void switchToEdit(String space, String page)
+ {
+ getUtil().gotoPage(space, page, "edit", "editor=class");
+ }
+
+ public DatabaseListClassEditElement getDatabaseListClassEditElement(String
propertyName)
+ {
+ // Make the element visible before returning it
+ By locator = By.id("xproperty_" + propertyName + "_title");
+ waitUntilElementIsVisible(locator);
+ getDriver().findElement(locator).click();
+ return new DatabaseListClassEditElement(getForm(), propertyName);
+ }
+
+ public void clickSaveAndContinue()
+ {
+ this.saveandcontinue.click();
+
+ // Wait until the page is really saved
+
waitUntilElementIsVisible(By.xpath("//div[contains(@class,'xnotification-done')
and text()='Saved']"));
+ }
+
+ public ViewPage clickSaveAndView()
+ {
+ this.saveandview.click();
+ return new ViewPage();
+ }
+
+ public ViewPage clickCancel()
+ {
+ this.cancel.click();
+ return new ViewPage();
+ }
+}
Property changes on:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ClassEditPage.java
___________________________________________________________________
Name: svn:keywords
+ Author Id Revision HeadURL
Name: svn:eol-style
+ native
Added:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/DatabaseListClassEditElement.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/DatabaseListClassEditElement.java
(rev 0)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/DatabaseListClassEditElement.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -0,0 +1,51 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.it.ui.framework.elements;
+
+import org.openqa.selenium.By;
+
+/**
+ * Represents a DatabaseListClass property form.
+ *
+ * @version $Id$
+ * @since 2.4M2
+ */
+public class DatabaseListClassEditElement extends BaseElement
+{
+ private String propertyName;
+
+ private FormElement form;
+
+ public DatabaseListClassEditElement(FormElement form, String propertyName)
+ {
+ this.form = form;
+ this.propertyName = propertyName;
+ }
+
+ public void setHibernateQuery(String value)
+ {
+ this.form.setFieldValue(By.id(this.propertyName + "_sql"), value);
+ }
+
+ public void isMultiSelect(boolean isMultiSelect)
+ {
+ this.form.setFieldValue(By.id(this.propertyName + "_multiSelect"),
isMultiSelect ? "true" : "false");
+ }
+}
Property changes on:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/DatabaseListClassEditElement.java
___________________________________________________________________
Name: svn:keywords
+ Author Id Revision HeadURL
Name: svn:eol-style
+ native
Deleted:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditObjectsPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditObjectsPage.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditObjectsPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -1,117 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.xwiki.it.ui.framework.elements;
-
-import java.util.Set;
-import java.util.List;
-import java.util.ArrayList;
-
-import org.openqa.selenium.RenderedWebElement;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.WebDriverException;
-import org.openqa.selenium.By;
-
-/**
- * Represents the common actions possible editing objects on a page.
- *
- * @version $Id$
- * @since 2.4M2
- */
-public class EditObjectsPage extends EditPage
-{
- public String getURL(String space, String page)
- {
- return getUtil().getURL(space, page, "edit",
"editor=object");
- }
-
- public void clickPreview()
- {
- throw new WebDriverException("Preview not available in object
editor");
- }
-
- /** className will look something like "XWiki.XWikiRights" */
- public List<FormElement> getObjectsOfClass(String className)
- {
- List<WebElement> titles =
getDriver().findElement(By.id("xclass_" + className))
-
.findElements(By.className("xobject-title"));
- List<WebElement> elements =
getDriver().findElement(By.id("xclass_" + className))
-
.findElements(By.className("xobject-content"));
- List<FormElement> forms = new
ArrayList<FormElement>(elements.size());
- for (int i = 0; i < elements.size(); i++) {
- WebElement element = elements.get(i);
- // Make sure all forms are displayed otherwise we can't interact with
them.
- if (element instanceof RenderedWebElement && !((RenderedWebElement)
element).isDisplayed()) {
- titles.get(i).click();
- }
- forms.add(new FormElement(element));
- }
- return forms;
- }
-
- /**
- * Adding an object is easy, you simply say:
- * page.getAddPanel().selectClass("XWiki.XWikiRights").clickAdd();
- */
- public AddObjectPanel getAddPanel()
- {
- return this.new AddObjectPanel();
- }
-
- public class AddObjectPanel
- {
- private WebElement form;
-
- private FormElement.SelectElement classSelector;
-
- private WebElement getForm()
- {
- if (form == null) {
- form = getDriver().findElement(By.id("objectadd"));
- }
- return form;
- }
-
- private FormElement.SelectElement getClassSelector()
- {
- if (classSelector == null) {
- classSelector = new
FormElement(getForm()).getSelectElement(By.name("classname"));
- }
- return classSelector;
- }
-
- public AddObjectPanel selectClass(String name)
- {
- getClassSelector().select(name);
- return this;
- }
-
- public Set<String> getOptions()
- {
- return getClassSelector().getOptions();
- }
-
- public void clickAdd()
- {
- getForm().findElement(By.className("button")).click();
- }
- }
-
-
-}
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditPage.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/EditPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -31,9 +31,6 @@
*/
public class EditPage extends BasePage
{
- @FindBy(name = "action_preview")
- private WebElement preview;
-
@FindBy(name = "action_saveandcontinue")
private WebElement saveandcontinue;
@@ -43,11 +40,6 @@
@FindBy(name = "action_cancel")
private WebElement cancel;
- public void clickPreview()
- {
- preview.click();
- }
-
public void clickSaveAndContinue()
{
saveandcontinue.click();
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/FormElement.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/FormElement.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/FormElement.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -28,7 +28,6 @@
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
-import org.xwiki.it.ui.framework.elements.BaseElement;
/**
* Represents a Form.
@@ -75,11 +74,18 @@
public void setFieldValue(WebElement fieldElement, String value)
{
- if (!fieldElement.getTagName().equals("input") &&
!fieldElement.getTagName().equals("textarea")) {
- throw new WebDriverException("You can only fill in input and textarea
elements.");
- }
if ("checkbox".equals(fieldElement.getAttribute("type"))) {
setCheckBox(fieldElement, value.equals("true"));
+ } else if ("select".equals(fieldElement.getTagName())) {
+ // TODO: Should we do this? (don't seem to work)
+ //SelectElement select = new SelectElement(fieldElement);
+ //select.select(value);
+ List<WebElement> allOptions =
fieldElement.findElements(By.tagName("option"));
+ for (WebElement option : allOptions) {
+ if (value.equals(option.getValue())) {
+ option.setSelected();
+ }
+ }
} else {
fieldElement.clear();
fieldElement.sendKeys(value);
Added:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ObjectEditPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ObjectEditPage.java
(rev 0)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ObjectEditPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -0,0 +1,97 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.it.ui.framework.elements;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.RenderedWebElement;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+/**
+ * Represents the common actions possible on all Pages when using the "edit"
action with the "object" editor.
+ *
+ * @version $Id$
+ * @since 2.4M2
+ */
+public class ObjectEditPage extends EditPage
+{
+ @FindBy(id ="update")
+ private WebElement objectForm;
+
+ @FindBy(id = "classname")
+ private WebElement classNameField;
+
+ @FindBy(name = "action_objectadd")
+ private WebElement classNameSubmit;
+
+ private FormElement form;
+
+ public FormElement addObject(String className)
+ {
+ getForm().setFieldValue(this.classNameField, className);
+ this.classNameSubmit.click();
+
+ // Make sure we wait for the element to appear since there's no page
refresh.
+ waitUntilElementIsVisible(By.id("xclass_" + className));
+
+ List<FormElement> objects = getObjectsOfClass(className);
+ return objects.get(objects.size() - 1);
+ }
+
+ private FormElement getForm()
+ {
+ if (this.form == null) {
+ this.form = new FormElement(this.objectForm);
+ }
+ return this.form;
+ }
+
+ public String getURL(String space, String page)
+ {
+ return getUtil().getURL(space, page, "edit",
"editor=object");
+ }
+
+ /** className will look something like "XWiki.XWikiRights" */
+ public List<FormElement> getObjectsOfClass(String className)
+ {
+ List<WebElement> titles =
getDriver().findElement(By.id("xclass_" + className))
+
.findElements(By.className("xobject-title"));
+ List<WebElement> elements =
getDriver().findElement(By.id("xclass_" + className))
+
.findElements(By.className("xobject-content"));
+ List<FormElement> forms = new
ArrayList<FormElement>(elements.size());
+ for (int i = 0; i < elements.size(); i++) {
+ WebElement element = elements.get(i);
+ // Make sure all forms are displayed otherwise we can't interact with
them.
+ if (element instanceof RenderedWebElement && !((RenderedWebElement)
element).isDisplayed()) {
+ titles.get(i).click();
+ }
+ forms.add(new FormElement(element));
+ }
+ return forms;
+ }
+
+ public void switchToEdit(String space, String page)
+ {
+ getUtil().gotoPage(space, page, "edit", "editor=object");
+ }
+}
Property changes on:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ObjectEditPage.java
___________________________________________________________________
Name: svn:keywords
+ Author Id Revision HeadURL
Name: svn:eol-style
+ native
Added:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/PreviewableEditPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/PreviewableEditPage.java
(rev 0)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/PreviewableEditPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -0,0 +1,40 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.it.ui.framework.elements;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+/**
+ * Edit page with a preview button.
+ *
+ * @version $Id$
+ * @since 2.4M2
+ */
+public class PreviewableEditPage extends EditPage
+{
+ @FindBy(name = "action_preview")
+ private WebElement preview;
+
+ public void clickPreview()
+ {
+ preview.click();
+ }
+}
Property changes on:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/PreviewableEditPage.java
___________________________________________________________________
Name: svn:keywords
+ Author Id Revision HeadURL
Name: svn:eol-style
+ native
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ViewPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ViewPage.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/ViewPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -57,6 +57,9 @@
@FindBy(id = "tmAdminWiki")
private WebElement administerWikiMenuLink;
+ @FindBy(id = "xwikicontent")
+ private WebElement content;
+
/**
* Logs in the Admin user (move to the home page if the current page has no log in
link).
*/
@@ -159,4 +162,13 @@
}
return true;
}
+
+ /**
+ * @return the page's main content
+ * @since 2.4M2
+ */
+ public String getContent()
+ {
+ return this.content.getText();
+ }
I don't know what getText() will do in this instance, the content inside of
xwikicontent is HTML so IMO it should return the WebElement.
}
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WYSIWYGEditPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WYSIWYGEditPage.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WYSIWYGEditPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -28,7 +28,7 @@
* @version $Id$
* @since 2.3M1
*/
-public class WYSIWYGEditPage extends EditPage
+public class WYSIWYGEditPage extends PreviewableEditPage
{
@FindBy(id = "xwikidoctitleinput")
private WebElement titleField;
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WikiEditPage.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WikiEditPage.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/framework/elements/WikiEditPage.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -28,7 +28,7 @@
* @version $Id$
* @since 2.4M1
*/
-public class WikiEditPage extends EditPage
+public class WikiEditPage extends PreviewableEditPage
{
@FindBy(id = "xwikidoctitleinput")
private WebElement titleInput;
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/invitation/InvitationTest.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/invitation/InvitationTest.java 2010-06-28
13:29:41 UTC (rev 29787)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/invitation/InvitationTest.java 2010-06-28
13:36:43 UTC (rev 29788)
@@ -37,6 +37,7 @@
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.xwiki.it.ui.administration.elements.AdminSectionPage;
+import org.xwiki.it.ui.framework.elements.ObjectEditPage;
import org.xwiki.it.ui.invitation.elements.InvitationSenderPage;
import org.xwiki.it.ui.invitation.elements.InvitationMessageDisplayElement;
import org.xwiki.it.ui.framework.elements.TableElement;
@@ -44,7 +45,6 @@
import org.xwiki.it.ui.invitation.elements.InvitationActionConfirmationElement;
import org.xwiki.it.ui.invitation.elements.InvitationGuestActionsPage;
import org.xwiki.it.ui.framework.elements.RegisterPage;
-import org.xwiki.it.ui.framework.elements.EditObjectsPage;
import org.xwiki.it.ui.framework.AbstractTest;
import org.xwiki.it.ui.framework.TestUtils;
@@ -508,13 +508,13 @@
TestUtils.Session admin = getUtil().getSession();
try {
// First we ban anon from registering.
- EditObjectsPage eop = new EditObjectsPage();
- getDriver().get(eop.getURL("XWiki",
"XWikiPreferences"));
+ ObjectEditPage oep = new ObjectEditPage();
+ getDriver().get(oep.getURL("XWiki",
"XWikiPreferences"));
- eop.getObjectsOfClass("XWiki.XWikiGlobalRights").get(2)
+ oep.getObjectsOfClass("XWiki.XWikiGlobalRights").get(2)
.getSelectElement(By.name("XWiki.XWikiGlobalRights_2_levels")).unSelect("register");
- eop.clickSaveAndContinue();
+ oep.clickSaveAndContinue();
// now prove anon cannot register
getUtil().setSession(null);
new RegisterPage().gotoPage();
@@ -554,13 +554,13 @@
getUtil().setSession(admin);
// Better open the wiki back up again.
- EditObjectsPage eop = new EditObjectsPage();
- getDriver().get(eop.getURL("XWiki",
"XWikiPreferences"));
+ ObjectEditPage oep = new ObjectEditPage();
+ getDriver().get(oep.getURL("XWiki",
"XWikiPreferences"));
- eop.getObjectsOfClass("XWiki.XWikiGlobalRights").get(2)
+ oep.getObjectsOfClass("XWiki.XWikiGlobalRights").get(2)
.getSelectElement(By.name("XWiki.XWikiGlobalRights_2_levels")).select("register");
- eop.clickSaveAndContinue();
+ oep.clickSaveAndContinue();
}
}
_______________________________________________
notifications mailing list
notifications(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications