Skip to content

Commit c358a0c

Browse files
authored
Merge pull request #354 from webauthn4j/webauthn-webdriver-extension
Update selenium-java to use WebAuthn WebDriver extension
2 parents f6cdf2d + 368681d commit c358a0c

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,15 @@ configure(allJavaProjects) {
196196
def dbunitVersion = '2.7.0'
197197
def springTestDbunitVersion = '1.3.0'
198198
def webDriverManagerVersion = '3.8.1'
199+
// To use WebAuthn WebDriver extension, alpha release is used here.
200+
// When stable version is released, and Spring Boot BOM includes it, this need to be removed.
201+
def seleniumVersion = '4.0.0-alpha-6'
199202

200203
dependencies {
204+
// BOM
205+
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
206+
implementation platform("org.springframework.security:spring-security-bom:${springSecurityVersion}")
207+
201208
constraints {
202209
// Independent libraries
203210
implementation("com.webauthn4j:webauthn4j-util:$webauthn4jVersion")
@@ -214,11 +221,8 @@ configure(allJavaProjects) {
214221
implementation("org.dbunit:dbunit:$dbunitVersion")
215222
implementation("com.github.springtestdbunit:spring-test-dbunit:$springTestDbunitVersion")
216223
implementation("io.github.bonigarcia:webdrivermanager:$webDriverManagerVersion")
224+
implementation("org.seleniumhq.selenium:selenium-java:$seleniumVersion")
217225
}
218-
// BOM
219-
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
220-
implementation platform("org.springframework.security:spring-security-bom:${springSecurityVersion}")
221-
222226
}
223227

224228
check.dependsOn dependencyCheckAnalyze

samples/spa/src/test/java/e2e/RegistrationAndAuthenticationE2ETest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@
3232
import org.openqa.selenium.chrome.ChromeOptions;
3333
import org.openqa.selenium.support.ui.ExpectedConditions;
3434
import org.openqa.selenium.support.ui.WebDriverWait;
35+
import org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator;
36+
import org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions;
3537
import org.springframework.boot.test.context.SpringBootTest;
3638
import org.springframework.test.context.junit4.SpringRunner;
3739

40+
import java.time.Duration;
3841
import java.util.concurrent.TimeUnit;
3942

4043
@RunWith(SpringRunner.class)
@@ -52,10 +55,9 @@ public static void setupClassTest() {
5255
@Before
5356
public void setupTest() {
5457
ChromeOptions chromeOptions = new ChromeOptions();
55-
chromeOptions.addArguments("--enable-web-authentication-testing-api");
5658
chromeOptions.setHeadless(true);
5759
driver = new ChromeDriver(chromeOptions);
58-
wait = new WebDriverWait(driver, 5);
60+
wait = new WebDriverWait(driver, Duration.ofSeconds(5));
5961
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
6062
}
6163

@@ -68,6 +70,10 @@ public void teardown() {
6870

6971
@Test
7072
public void test() {
73+
74+
VirtualAuthenticatorOptions options = new VirtualAuthenticatorOptions();
75+
((HasVirtualAuthenticator) driver).addVirtualAuthenticator(options);
76+
7177
// Registration
7278
SignupComponent signupComponent = new SignupComponent(driver);
7379
signupComponent.navigate();

samples/spa/src/test/java/e2e/page/ProfileComponent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.openqa.selenium.WebDriver;
2020
import org.openqa.selenium.support.ui.WebDriverWait;
2121

22+
import java.time.Duration;
23+
2224
public class ProfileComponent {
2325

2426
private final WebDriver webDriver;
@@ -27,7 +29,7 @@ public class ProfileComponent {
2729

2830
public ProfileComponent(WebDriver webDriver) {
2931
this.webDriver = webDriver;
30-
this.wait = new WebDriverWait(webDriver, 50);
32+
this.wait = new WebDriverWait(webDriver, Duration.ofSeconds(50));
3133
}
3234

3335
}

samples/spa/src/test/java/e2e/page/SignupComponent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.openqa.selenium.support.ui.ExpectedConditions;
2222
import org.openqa.selenium.support.ui.WebDriverWait;
2323

24+
import java.time.Duration;
25+
2426
public class SignupComponent {
2527

2628
private final WebDriver webDriver;
@@ -29,7 +31,7 @@ public class SignupComponent {
2931

3032
public SignupComponent(WebDriver webDriver) {
3133
this.webDriver = webDriver;
32-
this.wait = new WebDriverWait(webDriver, 5);
34+
this.wait = new WebDriverWait(webDriver, Duration.ofSeconds(5));
3335
this.residentKeyRequirementDialog = new ResidentKeyRequirementDialog(webDriver);
3436
}
3537

0 commit comments

Comments
 (0)