selenium-jupiter
selenium-jupiter copied to clipboard
Let HtmlUnitDriver be chosen as a substitute to Selenium WebDriver
Purpose of changes
In the past I needed to change the signature of my unittest to be able to run it with HtmlUnit instead of with a slow browser. As HtmlUnitDriver implements WebDriver it seems logical to be able to use it as a pretend Selenium WebDriver when adding "-Dwdm.defaultBrowser=HTMLUNIT" to the command line.
// use -Dwdm.defaultBrowser=HTMLUNIT to run with htmlunit instead of a slow browser
@ExtendWith(SeleniumJupiter.class)
class HelloServletIT {
@Test
void shouldEchoName(WebDriver driver) {
String expected = "example;
String actual = HelloServletPage.go(driver).submitName(expected);
assertThat(actual, is(expected));
}
}
Types of changes
- [ ] Bug-fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
How has this been tested?
I've run the unittests and they pass except for the chrome ones, but that is because I'm on linux. I've run "mvn install" on this project then used it on my selenium project by replacing the dependency like this:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>selenium-jupiter</artifactId>
<version>5.1.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>