Skip to content

Latest commit

 

History

History

webdrivershooter-testng

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Java Maven GitHub Actions

WebDriverShooter for TestNG

Table of Contents

When using TestNG as a testing framework, webdrivershooter-testng should be used.

  • WebDriverShooter automatically gets WebDriver instance from the current running test by using org.testng.ITestNGListener listener.
  • You don't need to pass the WebDriver instance to the argument of shooting methods.
webdrivershooter webdrivershooter-testng
WebDriverShooter.page(driver) WebDriverShooter.page()

Declaration

Gradle

Add to build.gradle

implementation("com.github.ngoanh2n:webdrivershooter-testng:1.1.1")

Maven

Add to pom.xml

<dependency>
    <groupId>com.github.ngoanh2n</groupId>
    <artifactId>webdrivershooter-testng</artifactId>
    <version>1.1.1</version>
</dependency>

Test Structure

  1. Must declare a field of WebDriver type with any modifiers at current class or parent/abstract class.
  2. WebDriverShooter can detect WebDriver instance after the field is assigned a value.
public class MyTest {
    private WebDriver driver;

    @BeforeClass
    public void beforeClass() {
        driver = new ChromeDriver();
        // WebDriverShooter could find WebDriver instance from here.
        // WebDriverShooter.page(driver) <=> WebDriverShooter.page()
    }
}