Skip to content

Commit

Permalink
XWIKI-16210: Save of document should only be done when hitting save b…
Browse files Browse the repository at this point in the history
…utton in object editor

  * Fix ObjectEditPane page object to be usable also outside of the
    object editor and add some doc.
  • Loading branch information
surli committed May 14, 2020
1 parent b838569 commit 68e3ad5
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public class ObjectEditPane extends FormContainerElement
*/
private int objectNumber;

private WebElement xobjectContainer;

/**
* Creates a new edit pane for an object of the specified type. The form fields from the given container should
* correspond to properties of the specified type.
Expand All @@ -59,7 +57,6 @@ public ObjectEditPane(By containerLocator, String className, int objectNumber)

this.className = className;
this.objectNumber = objectNumber;
this.xobjectContainer = getDriver().findElementById(String.format("%s_%s_%s", "xobject", className, objectNumber));
}

/**
Expand Down Expand Up @@ -124,24 +121,45 @@ public ObjectEditPane setPropertyValue(String propertyName, String propertyValue
return this;
}

/**
* @return the div container of the current object edit. Note that this should only be used in the case of
* ObjectEditor.
*/
private WebElement getXobjectContainer()
{
return getDriver().findElementById(String.format("%s_%s_%s", "xobject", className, objectNumber));
}

/**
* @return {@code true} if the delete link is displayed for this object.
* @since 12.4RC1
*/
public boolean isDeleteLinkDisplayed()
{
try {
return this.xobjectContainer.findElement(By.className("delete")).isDisplayed();
return getXobjectContainer().findElement(By.className("delete")).isDisplayed();
} catch (NoSuchElementException e) {
return false;
}
}

/**
* @return {@code true} if the edit link is displayed for this object.
* @since 12.4RC1
*/
public boolean isEditLinkDisplayed()
{
try {
return this.xobjectContainer.findElement(By.className("edit")).isDisplayed();
return getXobjectContainer().findElement(By.className("edit")).isDisplayed();
} catch (NoSuchElementException e) {
return false;
}
}

/**
* @return the current object number.
* @since 12.4RC1
*/
public int getObjectNumber()
{
return objectNumber;
Expand Down

0 comments on commit 68e3ad5

Please sign in to comment.