Table of Contents
When using JUnit Jupiter as a testing framework, webdriverchecker-junit5
should be used.
WebDriverChecker
automatically getWebDriver
instance from the current running test by usingorg.junit.jupiter.api.extension.InvocationInterceptor
extension.- You don't need to pass the
WebDriver
instance to the argument of checker methods.
webdriverchecker | webdriverchecker-junit5 |
---|---|
WebDriverChecker.isChrome(driver) |
WebDriverChecker.isChrome() |
Add to build.gradle
.
implementation("com.github.ngoanh2n:webdriverchecker-junit5:2.9.0")
Add to pom.xml
.
<dependency>
<groupId>com.github.ngoanh2n</groupId>
<artifactId>webdriverchecker-junit5</artifactId>
<version>2.9.0</version>
</dependency>
- Must declare a field of
WebDriver
type with any modifiers at current class or parent/abstract class. WebDriverChecker
can detectWebDriver
instance after the field is assigned a value.
public class MyTest {
private WebDriver driver;
@BeforeAll
public static void beforeAll() {
driver = new ChromeDriver();
// WebDriverChecker could find WebDriver instance from here.
// WebDriverChecker.isChrome(driver) <=> WebDriverChecker.isChrome()
}
}