Search in sources :

Example 6 with UserPicker

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");
}
Also used : UserClassFieldEditPane(org.xwiki.appwithinminutes.test.po.UserClassFieldEditPane) InlinePage(org.xwiki.test.ui.po.InlinePage) ClassSheetPage(org.xwiki.xclass.test.po.ClassSheetPage) WebElement(org.openqa.selenium.WebElement) UserPicker(org.xwiki.test.ui.po.editor.UserPicker) UserElement(org.xwiki.test.ui.po.editor.UserPicker.UserElement) Test(org.junit.Test)

Aggregations

UserPicker (org.xwiki.test.ui.po.editor.UserPicker)6 Test (org.junit.Test)5 UserClassFieldEditPane (org.xwiki.appwithinminutes.test.po.UserClassFieldEditPane)5 UserElement (org.xwiki.test.ui.po.editor.UserPicker.UserElement)5 WebElement (org.openqa.selenium.WebElement)1 InlinePage (org.xwiki.test.ui.po.InlinePage)1 ClassSheetPage (org.xwiki.xclass.test.po.ClassSheetPage)1