0

I use selenium webdriver to automate my test-cases.

My objective to execute headless browser using HtmlUnitDriver on a sample selenium script. Please find the script mentioned below:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Headless 
{
    public static void main(String[] args) throws InterruptedException
    {
        HtmlUnitDriver driver = new HtmlUnitDriver();
        //driver.setJavascriptEnabled(true);

       // WebDriver driver=new FirefoxDriver();

        driver.get("https://www.google.co.in/?gfe_rd=cr&ei=k36cVsa6OubI8Aec14bICQ&gws_rd=ssl"); 

        /*WebDriverWait wait=new WebDriverWait(driver,120);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.id("sb_ifc0")));
        */
        Thread.sleep(50000);
        System.out.println("URL= "+driver.getCurrentUrl());

        System.out.println("Page title is: " + driver.getTitle());     
    }
}

And the output is:

URL= about:blank
Page title is: 

The output is working fine for FirefoxDriver()

Could anyone guide where I went wrong?

TodayILearned
  • 1,440
  • 4
  • 20
  • 28
  • 2
    Possible duplicate of [Script not working in HtmlUnitDriver](http://stackoverflow.com/questions/34848433/script-not-working-in-htmlunitdriver) – Mrunal Gosar Jan 20 '16 at 06:54
  • 1
    i believe you've already asked this question here: http://stackoverflow.com/questions/34848433/script-not-working-in-htmlunitdriver – Mrunal Gosar Jan 20 '16 at 06:54

0 Answers0