HtmlUnitDriver is not working properly. Below are the sample code. What am i doing wrong?
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.gargoylesoftware.htmlunit.BrowserVersion;
public class HtmlUnitDriver_Example
{
public static HtmlUnitDriver driver = null;
@BeforeClass
public void setUp()
{
driver = new HtmlUnitDriver(BrowserVersion.INTERNET_EXPLORER_11);
driver.setJavascriptEnabled(true);
}
@Test
public void Test_01()
{
System.out.println("Trying to execute Test_01");
driver.get("https://www.google.co.in");
System.out.println(driver.getPageSource());
System.out.println(driver.getTitle());
}
@AfterClass
public void tearDown()
{
driver.quit();
}
}
Below two lines are not returning anything meaningful on console.
System.out.println(driver.getPageSource());
System.out.println(driver.getTitle());
Instead, I got the following output;
[TestNG] Running:
C:\Users\acer\AppData\Local\Temp\testng-eclipse--592945208\testng-customsuite.xml
Trying to execute Test_01
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head/>
<body/>
</html>
PASSED: Test_01
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================
Please help.