Table of Contents
When using TestNG as a testing framework, webdriverchecker-testng
should be used.
WebDriverChecker
automatically getWebDriver
instance from the current running test by usingorg.testng.ITestNGListener
listener.- You don't need to pass the
WebDriver
instance to the argument of checker methods.
webdriverchecker | webdriverchecker-testng |
---|---|
WebDriverChecker.isChrome(driver) |
WebDriverChecker.isChrome() |
Add to build.gradle
.
implementation("com.github.ngoanh2n:webdriverchecker-testng:2.9.0")
Add to pom.xml
.
<dependency>
<groupId>com.github.ngoanh2n</groupId>
<artifactId>webdriverchecker-testng</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;
@BeforeClass
public void beforeClass() {
driver = new ChromeDriver();
// WebDriverChecker could find WebDriver instance from here.
// WebDriverChecker.isChrome(driver) <=> WebDriverChecker.isChrome()
}
}