Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Last active January 17, 2023 19:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadvolod/286c9d88fed836547367453d5ffa0781 to your computer and use it in GitHub Desktop.
Save nadvolod/286c9d88fed836547367453d5ffa0781 to your computer and use it in GitHub Desktop.
How to use WebDriverManager with Junit 4
import io.github.bonigarcia.wdm.WebDriverManager;
//This method will run once before all of the tests in our class
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
//The setup() will run one time before every single @Test method
//In our case it will instantiate a new ChromeDriver that WebDriverManager setup for us
@Before
public void setup()
{
driver = new ChromeDriver();
}
//You need to add WebDriverManager dependency to your POM.xml
// https://github.com/bonigarcia/webdrivermanager/
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment