I am working with the WebDriverManager java library. It provides a generic manager that can be parameterized to act as a specific manager (for Chrome, Firefox, etc.). I am using it with Selenium Webdriver and Junit 5's @Parameterized and @ValueSource annotations so that I can run my tests on multiple browsers. I created an implementation as per the WebDriverManager documentation:
public class WebTest {
WebDriver driver = null;
@ParameterizedTest
@ValueSource(classes = { ChromeDriver.class, FirefoxDriver.class })
public void navigateToUrl(String url, Class<? extends WebDriver> webDriverClass) { //WebDriver class gets extended
driver = WebDriverManager.getInstance(webDriverClass).create();
driver.manage().window().maximize();
driver.get(url);
In the class containing my Cucumber step definitions, I tried calling the navigateToUrl
method, but there was a compilation error like this:
public class WebAppStepDefinitions {
private final WebTest webTest = new WebTest();
@Given("^I have navigated to the web url \"([^\"]*)\"$")
public void navigateToUrl(String url) {
webTest.navigateToUrl(url, Class<? extends WebDriver > webDriverClass); //error on this line: `Cannot resolve symbol webDriverClass`
}
How Do I correctly call the navigateToUrl
located in the WebTest
class?