Skip to content
Snippets Groups Projects
Commit 4bcd6db9 authored by srosse's avatar srosse
Browse files

OO-4224: selenium test for the registration process

parent e857c5fd
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,10 @@ public class EmailSendingForm extends FormBasicController {
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_registration_email_form");
mail = uifactory.addTextElement("mail", "email.address", 255, "", formLayout);
mail.setElementCssClass("o_sel_registration_email");
mail.setMandatory(true);
// Button layout
......
......@@ -168,6 +168,7 @@ public class RegistrationForm2 extends FormBasicController {
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("title.register");
formLayout.setElementCssClass("o_sel_registration_2_form");
// first the configured user properties
userPropertyHandlers = userManager.getUserPropertyHandlersFor(USERPROPERTIES_FORM_IDENTIFIER, false);
......@@ -179,6 +180,7 @@ public class RegistrationForm2 extends FormBasicController {
FormItem fi = userPropertyHandler
.addFormItem(getLocale(), null, USERPROPERTIES_FORM_IDENTIFIER, false, formLayout);
fi.setElementCssClass("o_sel_registration_" + userPropertyHandler.getName());
fi.setTranslator(tr);
propFormItems.put(userPropertyHandler.getName(), fi);
......@@ -205,6 +207,7 @@ public class RegistrationForm2 extends FormBasicController {
} else {
uifactory.addStaticTextElement("form.username.rules", null, translate("form.username.rules"), formLayout);
usernameEl = uifactory.addTextElement("username", "user.login", 128, "", formLayout);
usernameEl.setElementCssClass("o_sel_registration_login");
usernameEl.setMandatory(true);
}
......@@ -219,9 +222,11 @@ public class RegistrationForm2 extends FormBasicController {
uifactory.addStaticTextElement("form.password.rules", null,
translate("form.password.rules", new String[] { descriptions }), formLayout);
newpass1 = uifactory.addPasswordElement("newpass1", "form.password.new1", 5000, "", formLayout);
newpass1.setElementCssClass("o_sel_registration_cred1");
newpass1.setMandatory(true);
newpass1.setAutocomplete("new-password");
newpass2 = uifactory.addPasswordElement("newpass2", "form.password.new2", 5000, "", formLayout);
newpass2.setElementCssClass("o_sel_registration_cred2");
newpass2.setMandatory(true);
newpass2.setAutocomplete("new-password");
......
......@@ -22,23 +22,29 @@ package org.olat.selenium;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.UUID;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.olat.core.util.CodeHelper;
import org.olat.selenium.page.LoginPage;
import org.olat.selenium.page.NavigationPage;
import org.olat.selenium.page.Participant;
import org.olat.selenium.page.Student;
import org.olat.selenium.page.core.AdministrationMessagesPage;
import org.olat.selenium.page.user.RegistrationPage;
import org.olat.test.rest.UserRestClient;
import org.olat.user.restapi.UserVO;
import org.openqa.selenium.WebDriver;
import com.dumbster.smtp.SmtpMessage;
/**
*
* Initial date: 19.06.2014<br>
......@@ -122,8 +128,7 @@ public class LoginTest extends Deployments {
*/
@Test
@RunAsClient
public void maintenanceMessage(
@Drone @Participant WebDriver reiBrowser,
public void maintenanceMessage(@Drone @Participant WebDriver reiBrowser,
@Drone @Student WebDriver kanuBrowser)
throws IOException, URISyntaxException {
......@@ -165,4 +170,40 @@ public class LoginTest extends Deployments {
kanuLogin
.waitOnMaintenanceMessageCleared();
}
/**
* Someone wants to register.
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void registration()
throws IOException, URISyntaxException {
String email = UUID.randomUUID() + "@openolat.com";
//login
LoginPage loginPage = LoginPage.load(browser, deploymentUrl);
loginPage
.assertOnLoginPage();
RegistrationPage registration = RegistrationPage.getPage(browser)
.signIn()
.nextToDisclaimer()
.acknowledgeDisclaimer()
.register(email);
List<SmtpMessage> messages = getSmtpServer().getReceivedEmails();
Assert.assertEquals(1, messages.size());
String registrationLink = registration.extractRegistrationLink(messages.get(0));
Assert.assertNotNull(registrationLink);
String login = "md_" + CodeHelper.getForeverUniqueID();
String password = "VerySecret#01";
registration
.loadRegistrationLink(registrationLink)
.finalizeRegistration("Arisu", "Iwakura", login, password);
loginPage
.assertLoggedInByLastName("Iwakura");
}
}
......@@ -46,8 +46,8 @@ public class LoginPage {
public static final By loginFormBy = By.cssSelector("div.o_login_form");
private static final By authOrDisclaimerXPath = By.xpath(footerUserDivXPath + "|" + acknowledgeCheckboxXPath);
private static final By disclaimerXPath = By.xpath(acknowledgeCheckboxXPath);
private static final By disclaimerButtonXPath = By.xpath("//div[contains(@class,'o_sel_disclaimer_buttons')]/button");
public static final By disclaimerXPath = By.xpath(acknowledgeCheckboxXPath);
public static final By disclaimerButtonXPath = By.xpath("//div[contains(@class,'o_sel_disclaimer_buttons')]/button");
public static final By resumeButton = By.className("o_sel_resume_yes");
public static final By usernameFooterBy = By.id("o_username");
......@@ -73,7 +73,7 @@ public class LoginPage {
}
public LoginPage assertOnLoginPage() {
OOGraphene.waitElement(loginFormBy, 5, browser);
OOGraphene.waitElement(loginFormBy, browser);
return this;
}
......@@ -86,7 +86,7 @@ public class LoginPage {
}
public void assertLoggedInByLastName(String lastName) {
OOGraphene.waitElement(usernameFooterBy, 5, browser);
OOGraphene.waitElement(usernameFooterBy, browser);
WebElement username = browser.findElement(usernameFooterBy);
Assert.assertNotNull(username);
Assert.assertTrue(username.isDisplayed());
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.selenium.page.user;
import java.util.List;
import org.olat.selenium.page.LoginPage;
import org.olat.selenium.page.graphene.OOGraphene;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import com.dumbster.smtp.SmtpMessage;
/**
*
* Initial date: 5 sept. 2019<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class RegistrationPage {
private final WebDriver browser;
private RegistrationPage(WebDriver browser) {
this.browser = browser;
}
public static RegistrationPage getPage(WebDriver browser) {
return new RegistrationPage(browser);
}
public RegistrationPage signIn() {
By signInBy = By.id("o_co_olat_login_register");
OOGraphene.waitElement(signInBy, browser);
browser.findElement(signInBy).click();
OOGraphene.waitModalDialog(browser);
return this;
}
public RegistrationPage nextToDisclaimer() {
By languageBy = By.id("o_fioselect_language_SELBOX");
OOGraphene.waitElement(languageBy, browser);
new Select(browser.findElement(languageBy)).selectByValue("en");
OOGraphene.waitBusy(browser);
By nextBy = By.cssSelector(".modal-content .modal-body .form-group button.btn.btn-primary");
browser.findElement(nextBy).click();
OOGraphene.waitBusy(browser);
// wait disclaimer
By disclaimerBy = By.cssSelector("fieldset.o_disclaimer");
OOGraphene.waitElement(disclaimerBy, browser);
return this;
}
public RegistrationPage acknowledgeDisclaimer() {
List<WebElement> disclaimer = browser.findElements(LoginPage.disclaimerXPath);
disclaimer.get(0).click();
browser.findElement(LoginPage.disclaimerButtonXPath).click();
OOGraphene.waitBusy(browser);
By mailBy = By.className("o_sel_registration_email");
OOGraphene.waitElement(mailBy, browser);
return this;
}
public RegistrationPage register(String email) {
By emailBy = By.cssSelector(".o_sel_registration_email input[type='text']");
OOGraphene.waitElement(emailBy, browser);
browser.findElement(emailBy).sendKeys(email);
By sendBy = By.cssSelector("fieldset.o_sel_registration_email_form button.btn.btn-primary");
browser.findElement(sendBy).click();
OOGraphene.waitBusy(browser);
By confirmationBy = By.xpath("//p[text()[contains(.,'" + email + "')]]");
OOGraphene.waitElement(confirmationBy, browser);
return this;
}
public String extractRegistrationLink(SmtpMessage message) {
String body = message.getBody();
int index = body.indexOf("http");
if(index >= 0) {
int lastIndex = body.indexOf(' ', index + 1);
return body.substring(index, lastIndex);
}
return null;
}
public RegistrationPage loadRegistrationLink(String link) {
browser.navigate().to(link);
return this;
}
public void finalizeRegistration(String firstName, String lastName, String login, String password) {
By firstNameBy = By.cssSelector(".o_sel_registration_firstName input[type='text']");
OOGraphene.waitElement(firstNameBy, browser);
browser.findElement(firstNameBy).sendKeys(firstName);
By lastNameBy = By.cssSelector(".o_sel_registration_lastName input[type='text']");
browser.findElement(lastNameBy).sendKeys(lastName);
By loginBy = By.cssSelector(".o_sel_registration_login input[type='text']");
browser.findElement(loginBy).sendKeys(login);
By cred1By = By.cssSelector(".o_sel_registration_cred1 input[type='password']");
browser.findElement(cred1By).sendKeys(password);
By cred2By = By.cssSelector(".o_sel_registration_cred2 input[type='password']");
browser.findElement(cred2By).sendKeys(password);
By finalizeBy = By.cssSelector(".o_sel_registration_2_form button.btn.btn-primary");
browser.findElement(finalizeBy).click();
OOGraphene.waitBusy(browser);
By previewBy = By.id("o_preview_details");
OOGraphene.waitElement(previewBy, browser);
By toLoginBy = By.cssSelector("#o_main_center_content_inner a.btn.btn-primary");
browser.findElement(toLoginBy).click();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment