diff --git a/vaadin-testbench-core-junit5/src/main/java/com/vaadin/testbench/browser/BrowserExtension.java b/vaadin-testbench-core-junit5/src/main/java/com/vaadin/testbench/browser/BrowserExtension.java index 918c8250b..16ea8c024 100644 --- a/vaadin-testbench-core-junit5/src/main/java/com/vaadin/testbench/browser/BrowserExtension.java +++ b/vaadin-testbench-core-junit5/src/main/java/com/vaadin/testbench/browser/BrowserExtension.java @@ -215,13 +215,16 @@ private WebDriver createDriver(ExtensionContext context, Object testInstance = context.getRequiredTestInstance(); + WebDriver webDriver; + // use WebDriver provided by test instance if (testInstance instanceof DriverSupplier supplier) { - return supplier.createDriver(); + webDriver = supplier.createDriver(); + if (webDriver != null) { + return webDriver; + } } - WebDriver webDriver; - Class testClass = context.getRequiredTestClass(); // Always give priority to @RunLocally annotation if ((getRunLocallyBrowser(testClass) != null)) {