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?