Skip to content

Commit

Permalink
SDI-2122-713-5.5-Casos Uso VistaSignUp.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulasuarezp committed Mar 8, 2022
1 parent 74e346e commit 3197880
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 0 deletions.
144 changes: 144 additions & 0 deletions src/test/java/com/uniovi/sdi/Sdi2122713SpringApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.uniovi.sdi.pageobjects.PO_HomeView;
import com.uniovi.sdi.pageobjects.PO_Properties;
import com.uniovi.sdi.pageobjects.PO_SignUpView;
import com.uniovi.sdi.pageobjects.PO_View;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
Expand Down Expand Up @@ -90,4 +92,146 @@ public void PR04() {
PO_Properties.getSPANISH(), PO_Properties.getENGLISH());
}

//PR05. Prueba del formulario de registro. registro con datos correctos
@Test
@Order(6)
public void PR05() {
//Vamos al formulario de registro
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
//Rellenamos el formulario.
PO_SignUpView.fillForm(driver, "77777778A", "Josefo", "Perez", "77777", "77777");
//Comprobamos que entramos en la sección privada y nos nuestra el texto a buscar
String checkText = "Notas del usuario";
List<WebElement> result = PO_View.checkElementBy(driver, "text", checkText);
Assertions.assertEquals(checkText, result.get(0).getText());
}

//PR06A. Prueba del formulario de registro. DNI repetido en la BD
// Propiedad: Error.signup.dni.duplicate
@Test
@Order(7)
public void PR06A() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "99999990A", "Josefo", "Perez", "77777", "77777");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.dni.duplicate",
PO_Properties.getSPANISH() );
//Comprobamos el error de DNI repetido.
String checkText = PO_HomeView.getP().getString("Error.signup.dni.duplicate",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText , result.get(0).getText());
}
//PR06B. Prueba del formulario de registro. Nombre corto.
// Propiedad: Error.signup.name.length
@Test
@Order(8)
public void PR06B() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "99999990B", "Jose", "Perez", "77777", "77777");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.name.length",
PO_Properties.getSPANISH());
//Comprobamos el error de Nombre corto de nombre corto .
String checkText = PO_HomeView.getP().getString("Error.signup.name.length",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText, result.get(0).getText());
}

//PR06C. Prueba del formulario de registro. Apellido corto.
// Propiedad: Error.signup.lastName.length
@Test
@Order(9)
public void PR06C() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "99999990B", "Manuel", "Lima", "77777", "77777");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.lastName.length",
PO_Properties.getSPANISH());
//Comprobamos el error de apellido corto.
String checkText = PO_HomeView.getP().getString("Error.signup.lastName.length",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText, result.get(0).getText());
}


//PR06D. Prueba del formulario de registro. DNI corto.
// Propiedad: Error.signup.dni.length
@Test
@Order(10)
public void PR06D() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "90B", "Paula", "Suárez", "77777", "77777");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.dni.length",
PO_Properties.getSPANISH());
//Comprobamos el error de DNI corto .
String checkText = PO_HomeView.getP().getString("Error.signup.dni.length",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText, result.get(0).getText());
}

//PR06E. Prueba del formulario de registro. DNI largo.
// Propiedad: Error.signup.dni.length
@Test
@Order(11)
public void PR06E() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "900000000000000000000000000000000000000000000000000B",
"Paula", "Suárez", "77777", "77777");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.dni.length",
PO_Properties.getSPANISH());
//Comprobamos el error de DNI largo .
String checkText = PO_HomeView.getP().getString("Error.signup.dni.length",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText, result.get(0).getText());
}



//PR06F. Prueba del formulario de registro. Contraseña corta.
// Propiedad: Error.signup.password.length
@Test
@Order(12)
public void PR06F() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "34295806T",
"Paula", "Suárez", "0", "0");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.password.length",
PO_Properties.getSPANISH());
//Comprobamos el error de contraseña corta .
String checkText = PO_HomeView.getP().getString("Error.signup.password.length",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText, result.get(0).getText());
}

//PR06G. Prueba del formulario de registro. Contraseña larga.
// Propiedad: Error.signup.password.length
@Test
@Order(13)
public void PR06G() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "34295806T",
"Paula", "Suárez", "00000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.password.length",
PO_Properties.getSPANISH());
//Comprobamos el error de contraseña larga .
String checkText = PO_HomeView.getP().getString("Error.signup.password.length",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText, result.get(0).getText());
}


//PR06H. Prueba del formulario de registro. Contraseña no coincide.
// Propiedad: Error.signup.passwordConfirm.coincidence
@Test
@Order(14)
public void PR06H() {
PO_HomeView.clickOption(driver, "signup", "class", "btn btn-primary");
PO_SignUpView.fillForm(driver, "34295806T",
"Paula", "Suárez", "00000",
"000001");
List<WebElement> result = PO_SignUpView.checkElementByKey(driver, "Error.signup.passwordConfirm.coincidence",
PO_Properties.getSPANISH());
//Comprobamos el error de contraseña larga .
String checkText = PO_HomeView.getP().getString("Error.signup.passwordConfirm.coincidence",
PO_Properties.getSPANISH());
Assertions.assertEquals(checkText, result.get(0).getText());
}
}
40 changes: 40 additions & 0 deletions src/test/java/com/uniovi/sdi/pageobjects/PO_SignUpView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.uniovi.sdi.pageobjects;

import com.uniovi.sdi.util.SeleniumUtils;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.util.List;

public class PO_SignUpView extends PO_NavView {

static public void fillForm(WebDriver driver, String dnip, String namep, String lastnamep,
String passwordp, String passwordconfp) {
WebElement dni = driver.findElement(By.name("dni"));
dni.click();
dni.clear();
dni.sendKeys(dnip);
WebElement name = driver.findElement(By.name("name"));
name.click();
name.clear();
name.sendKeys(namep);
WebElement lastname = driver.findElement(By.name("lastName"));
lastname.click();
lastname.clear();
lastname.sendKeys(lastnamep);
WebElement password = driver.findElement(By.name("password"));
password.click();
password.clear();
password.sendKeys(passwordp);
WebElement passwordConfirm = driver.findElement(By.name("passwordConfirm"));
passwordConfirm.click();
passwordConfirm.clear();
passwordConfirm.sendKeys(passwordconfp);
//Pulsar el boton de Alta.
By boton = By.className("btn");
driver.findElement(boton).click();
}


}

0 comments on commit 3197880

Please sign in to comment.