Fix webflux usernamepassword:form tests

This commit is contained in:
Marcus Da Coregio
2023-06-21 16:20:20 -03:00
parent 23d6d5d826
commit d5c3f98bc6
3 changed files with 7 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test' testImplementation 'org.springframework.security:spring-security-test'

View File

@@ -24,7 +24,7 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
/** /**
* Integration tests for WebFlux based form log in sample. * Integration tests for WebFlux based form log in sample.

View File

@@ -16,6 +16,8 @@
package example.pages; package example.pages;
import java.util.List;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@@ -34,7 +36,7 @@ public class LoginPage {
private WebDriver driver; private WebDriver driver;
@FindBy(css = "div[role=alert]") @FindBy(css = "div[role=alert]")
private WebElement alert; private List<WebElement> alert;
private LoginForm loginForm; private LoginForm loginForm;
@@ -53,12 +55,12 @@ public class LoginPage {
} }
public LoginPage assertError() { public LoginPage assertError() {
assertThat(this.alert.getText()).isEqualTo("Invalid username and password."); assertThat(this.alert).extracting(WebElement::getText).contains("Invalid username and password.");
return this; return this;
} }
public LoginPage assertLogout() { public LoginPage assertLogout() {
assertThat(this.alert.getText()).isEqualTo("You have been logged out."); assertThat(this.alert).extracting(WebElement::getText).contains("You have been logged out.");
return this; return this;
} }