@Test
public void testObjectAddAndRemove()
{
ObjectEditPage oep = new ObjectEditPage();
oep.switchToEdit("Test", "EditObjectsTestObject");
FormElement object = oep.addObject("XWiki.XWikiUsers");
object.setFieldValue(By.id("XWiki.XWikiUsers_0_first_name"), "John");
// Add another object
FormElement object2 = oep.addObject("XWiki.XWikiUsers");
// Check that the unsaved value from the first object wasn't lost
Assert.assertEquals("John", object.getFieldValue(By.id("XWiki.XWikiUsers_0_first_name")));
// Check that the value from the second object is unset
Assert.assertEquals("", object2.getFieldValue(By.id("XWiki.XWikiUsers_1_first_name")));
// Delete the second object
oep.deleteObject("XWiki.XWikiUsers", 1);
// Let's save the form and check that changes were persisted.