1

When tried to execute the below code on FirefoxDriver(), code is executed very well.

WebDriver driver = new FirefoxDriver();

But When tried to execute the same code with HtmlUnitDriver()

WebDriver driver = new HtmlUnitDriver();

It throws an error

public void controller (String col1) throws Throwable{

        WebDriver driver = new HtmlUnitDriver();
        driver.get("http://sitename.com/signup");
        driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
        driver.manage().window().maximize();
        driver.findElement(By.xpath("//*[@id='FN']")).sendKeys("test");
        driver.findElement(By.xpath("//*[@id='LN']")).sendKeys("test");

Getting below error

htmlTextInput[<input class="span10" type="text" name="FN" value="" id="FN" autocomplete="off">] -> HtmlHtml[<html>]
HtmlTextInput[<input class="span10" type="text" name="FN" value="" id="FN" autocomplete="off">] -> HtmlHtml[<html>]
HtmlTextInput[<input class="span10" type="text" name="FN" value="" id="FN" autocomplete="off">] -> HtmlHtml[<html>]
HtmlBody[<body>] -> HtmlHtml[<html>]
Priyanshu
  • 3,040
  • 3
  • 27
  • 34
  • Behavior of html unti driver is really unpredictable and besides, you can't actually see the things happening.It might be unable to load java scripts and other required things.You can give a try by enabling java script for Html unit driver. `driver.setJavascriptEnabled(true);` – Priyanshu Sep 25 '14 at 11:04
  • If a headless browser is your requirement, you might also try PhantomJS – Doug Simmons Sep 25 '14 at 18:18

0 Answers0