use of org.xwiki.test.ui.po.editor.UserPicker in project xwiki-platform by xwiki.
the class UserClassFieldTest method testApplicationEntry.
@Test
public void testApplicationEntry() {
// Create the application class.
UserPicker userPicker = new UserClassFieldEditPane(editor.addField("User").getName()).getUserPicker();
userPicker.sendKeys("thomas").waitForSuggestions().sendKeys(Keys.ENTER);
editor.clickSaveAndView();
// Create the application entry.
ClassSheetPage classSheetPage = new ClassSheetPage();
InlinePage entryEditPage = classSheetPage.createNewDocument(getTestClassName(), getTestMethodName() + "Entry");
// Assert the initial value.
String id = getTestClassName() + "." + getTestMethodName() + "_0_user1";
userPicker = new UserPicker(getDriver().findElement(By.id(id)));
List<UserElement> selectedUsers = userPicker.waitToLoad().getAcceptedSuggestions();
Assert.assertEquals(1, selectedUsers.size());
assertUserElement(selectedUsers.get(0), "Thomas Mortagne");
Assert.assertEquals("", userPicker.getValue());
// Change the selected user.
userPicker.sendKeys("eduard").waitForSuggestions().sendKeys(Keys.ENTER).waitForSuggestionsToFadeOut();
// We wait for the page to load because Selenium doesn't do it all the time when Save & View is clicked.
entryEditPage.clickSaveAndView().waitUntilPageIsLoaded();
// Assert the view mode.
List<WebElement> users = getDriver().findElements(By.className("user"));
Assert.assertEquals(1, users.size());
assertUserElement(new UserElement(users.get(0)), "Eduard Moraru", "Enygma2002");
}
Aggregations