I came across an unusual issue with my automation tests while using the HtmlUnitDriver. I have been using the junit parameterized class to iterate over a list of urls to run some of my tests. The test runs just fine with other WebDriver implementations - InternetExplorerDriver, FirefoxDriver and ChromeDriver without any issues. However, with HtmlUnitDriver the test just terminates without any error message. While Debugging, I tried to print my data source (list of urls ) all I got was an empty array in case of HtmlUnitDriver but I get the urls in other WebDriver implementations. So, I am kind of confused how and why is this happenning.
My CoursePage pageobject method returns the urls in an ArrayList.
public ArrayList<String[]> getPageURLs() throws IOException {
ArrayList<String[]> forumURLs= new ArrayList<String[]>();
//forums is a List<WebElement> field on my PageObject that returns a list of elements
for(WebElement forum : forums)
{
String pageURLs = forum.getAttribute("href");
//I filter out some urls with if else statements and add only those that are required
forumURLs.add(new String[]{pageURLs});
}
return forumURLs;
}
This is the JUnit method that gets the data:
@Parameters
public static ArrayList<String[]> getURLs() throws IOException{
startBrowser(Browser.HTMLUNIT);
LoginPage loginPage =goToLoginPage();
HomePage homepage =loginPage.loginAs(username, password);
CoursePage coursepage = homepage.goToCourse();
return coursepage.getPageURLs();
}