Search in sources :

Example 1 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class LoginTest method loginAsNewUser.

/**
 * Create a new user and try to login with its credentials.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void loginAsNewUser(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserRestClient userClient = new UserRestClient(deploymentUrl);
    UserVO user = userClient.createRandomUser();
    // load dmz
    loginPage.assertOnLoginPage();
    // login
    loginPage.loginAs(user.getLogin(), user.getPassword());
}
Also used : UserVO(org.olat.user.restapi.UserVO) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 2 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class UserTest method movePortletToTheTop.

/**
 * Go to the portal, edit it, move the notes to the
 * top, quit editing, check the notes are the first
 * portlet in the view mode.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void movePortletToTheTop(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    loginPage.loginAs(user.getLogin(), user.getPassword());
    PortalPage portal = navBar.openPortal().assertPortlet(PortalPage.notesBy).edit().moveLeft(PortalPage.notesBy).moveUp(PortalPage.notesBy).moveUp(PortalPage.notesBy).moveUp(PortalPage.notesBy).moveRight(PortalPage.quickStartBy).moveDown(PortalPage.quickStartBy);
    // finish editing
    portal.finishEditing();
    // no inactive panel -> we are in view mode
    List<WebElement> portalInactive = browser.findElements(PortalPage.inactiveBy);
    Assert.assertTrue(portalInactive.isEmpty());
    // notes must be first
    List<WebElement> portlets = browser.findElements(By.className("o_portlet"));
    Assert.assertFalse(portlets.isEmpty());
    WebElement notesPortlet = portlets.get(0);
    String cssClass = notesPortlet.getAttribute("class");
    Assert.assertNotNull(cssClass);
    Assert.assertTrue(cssClass.contains("o_portlet_notes"));
}
Also used : UserVO(org.olat.user.restapi.UserVO) WebElement(org.openqa.selenium.WebElement) PortalPage(org.olat.selenium.page.user.PortalPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 3 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class UserTest method userSwitchLanguageSwitchToEnglish.

/**
 * Switch the language to german and after logout login to english
 * and check every time.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void userSwitchLanguageSwitchToEnglish(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    // set the languages preferences to german
    UserToolsPage userTools = new UserToolsPage(browser);
    userTools.openUserToolsMenu().openMySettings().assertOnUserSettings().openPreferences().assertOnUserPreferences().setLanguage("de");
    userTools.logout();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    WebElement usernameDE = browser.findElement(LoginPage.usernameFooterBy);
    boolean de = usernameDE.getText().contains("Eingeloggt als");
    Assert.assertTrue(de);
    List<WebElement> deMarker = browser.findElements(By.className("o_lang_de"));
    Assert.assertFalse(deMarker.isEmpty());
    // set the languages preferences to english
    userTools.openUserToolsMenu().openMySettings().openPreferences().setLanguage("en");
    userTools.logout();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    WebElement usernameEN = browser.findElement(LoginPage.usernameFooterBy);
    boolean en = usernameEN.getText().contains("Logged in as");
    Assert.assertTrue(en);
    List<WebElement> enMarker = browser.findElements(By.className("o_lang_en"));
    Assert.assertFalse(enMarker.isEmpty());
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) WebElement(org.openqa.selenium.WebElement) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 4 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class UserTest method userResetItsPreferences.

/**
 * Reset the preferences and check that a log out happens
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void userResetItsPreferences(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    UserToolsPage userTools = new UserToolsPage(browser);
    UserPreferencesPageFragment prefs = userTools.openUserToolsMenu().openMySettings().openPreferences();
    // reset the preferences
    prefs.resetPreferences();
    // check the user is log out
    loginPage.assertOnLoginPage();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) UserPreferencesPageFragment(org.olat.selenium.page.user.UserPreferencesPageFragment) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 5 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class UserTest method importExistingUsers.

/**
 * Import 1 new user and 1 existing, change the password and the last name
 * of the existing user.
 *
 * @param loginPage
 * @param existingUserBrowser
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void importExistingUsers(@InitialPage LoginPage loginPage, @Drone @User WebDriver existingUserBrowser, @Drone @Student WebDriver newUserBrowser) throws IOException, URISyntaxException {
    UserVO user1 = new UserRestClient(deploymentUrl).createRandomUser("tsukune");
    // login
    loginPage.assertOnLoginPage().loginAs("administrator", "openolat").resume();
    UserAdminPage userAdminPage = navBar.openUserManagement().openImportUsers();
    // start import wizard
    ImportUserPage importWizard = userAdminPage.startImport();
    String uuid = UUID.randomUUID().toString();
    String username1 = "moka-" + uuid;
    StringBuilder csv = new StringBuilder();
    UserVO newUser = importWizard.append(username1, "rosario02", "Moka", "Akashiya", csv);
    user1 = importWizard.append(user1, "Aono", "openolat2", csv);
    importWizard.fill(csv.toString()).nextData().assertGreen(1).assertWarn(1).updatePasswords().updateUsers().nextOverview().nextGroups().finish();
    OOGraphene.waitAndCloseBlueMessageWindow(browser);
    // existing user log in with its new password and check if its name was updated
    LoginPage userLoginPage = LoginPage.getLoginPage(existingUserBrowser, deploymentUrl);
    // tools
    userLoginPage.loginAs(user1.getLogin(), "openolat2").resume().assertLoggedInByLastName("Aono");
    // new user log in
    LoginPage newLoginPage = LoginPage.getLoginPage(newUserBrowser, deploymentUrl);
    // tools
    newLoginPage.loginAs(newUser.getLogin(), "rosario02").resume().assertLoggedInByLastName("Akashiya");
}
Also used : UserVO(org.olat.user.restapi.UserVO) UserAdminPage(org.olat.selenium.page.user.UserAdminPage) ImportUserPage(org.olat.selenium.page.user.ImportUserPage) LoginPage(org.olat.selenium.page.LoginPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)258 UserRestClient (org.olat.test.rest.UserRestClient)258 UserVO (org.olat.user.restapi.UserVO)258 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)254 NavigationPage (org.olat.selenium.page.NavigationPage)110 LoginPage (org.olat.selenium.page.LoginPage)108 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)102 QTI21Page (org.olat.selenium.page.qti.QTI21Page)96 URL (java.net.URL)88 File (java.io.File)86 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)84 UserToolsPage (org.olat.selenium.page.user.UserToolsPage)62 QTI21EditorPage (org.olat.selenium.page.qti.QTI21EditorPage)46 WebElement (org.openqa.selenium.WebElement)46 MembersPage (org.olat.selenium.page.course.MembersPage)36 AuthoringEnvPage (org.olat.selenium.page.repository.AuthoringEnvPage)34 GroupPage (org.olat.selenium.page.group.GroupPage)22 BinderPage (org.olat.selenium.page.portfolio.BinderPage)12 PortfolioV2HomePage (org.olat.selenium.page.portfolio.PortfolioV2HomePage)12 By (org.openqa.selenium.By)12