Reputation: 303
I am trying to automate the flow of a website which has a jquery sweet alert. When I use HtmlUnitDriver for headless browser testing then the sweet alert is considered as not visible. So when I tried to execute javascript to change div display to 'block' then I get some exceptions.
HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME);
driver.setJavascriptEnabled(true);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.someurl.com");
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('dummy').style.display= 'block';");
WebElement dummy = driver.findElement(By.id("dummy"));
System.out.println("dummy is displayed?:"+dummy.isDisplayed());
Exception with HtmlUnit 2.18 with Selenium Webdriver 2.48.2 :
org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function createHTMLDocument in object [object DOMImplementation]
Upvotes: 0
Views: 699
Reputation: 2879
This special issue was fixed with HtmlUnit 2.22 but in general you have to switch to the latest version (2.27 at the moment).
Upvotes: 1