Skip to content

Commit

Permalink
added signup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eurohlam committed Sep 17, 2019
1 parent 9074717 commit 38f2c45
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class SignUpPage extends AbstractPage {
private SelenideElement confirmPassword = $("input#confirmPassword");
private SelenideElement checkEmail = $("input#check_email");
private SelenideElement signUpBtn = $("button.btn");
private SelenideElement errorMessage = $("span.error");

@Override
public String getPath() {
Expand Down Expand Up @@ -86,4 +87,10 @@ public SignUpPage clickSignUp() {
this.signUpBtn.click();
return this;
}

@Step("Get error message")
public String errorMessage() {
errorMessage.shouldBe(Condition.visible);
return errorMessage.getText();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.roag.web;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;
import org.roag.config.Config;
import org.roag.pages.LoginPage;
import org.roag.pages.ProfilePage;
Expand All @@ -17,6 +14,7 @@
* Created by eurohlam on 17/08/19.
*/
@DisplayName("Login Page Tests")
@Tag("SECURITY")
public class LoginTest {

@Test
Expand Down
30 changes: 24 additions & 6 deletions rss-2-kindle-web-test/src/test/java/org/roag/web/SignUpTest.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
package org.roag.web;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;
import org.roag.pages.SignUpPage;

import static org.roag.pages.PageUtils.to;

@DisplayName("SignUp Page Tests")
@Tag("SECURITY")
public class SignUpTest {


@Test
@Disabled
void passwordValidationTest() {
@DisplayName("Test password confirmation")
void passwordConfirmationTest() {
String error = to(SignUpPage.class)
.setUsername("robot")
.setEmail("[email protected]")
.setPassword("robot1")
.setConfirmPassword("robot2")
.clickSignUp()
.errorMessage();
Assertions.assertTrue(error != null && error.contains("confirmation of password does not match"));
}

@Test
@DisplayName("Test if username already exists")
void existingUserTest() {
to(SignUpPage.class)
.signUpWith("test", "test", "[email protected]");
.signUpWith("robot", "robot1", "[email protected]");
String error = to(SignUpPage.class)
.signUpWith("robot", "robot1", "[email protected]")
.errorMessage();

Assertions.assertTrue(error != null && error.contains("username is already occupied"));
}
}

0 comments on commit 38f2c45

Please sign in to comment.