Currently, I am attempting to scrape the second page of Google search results using Ghost driver. To achieve this, I am utilizing JavaScript to navigate through the HTML source of the search results page and click on the page numbers at the bottom with Ghost driver. However, I encountered an error message as shown below:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
driver = new HtmlUnitDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("document.querySelectorAll('#foot span div table tbody tr td a')[2].click();");
Exception in thread "main" java.lang.UnsupportedOperationException: Javascript is not enabled for this HtmlUnitDriver instance
at org.openqa.selenium.htmlunit.HtmlUnitDriver.getPageToInjectScriptInto(HtmlUnitDriver.java:503)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.executeScript(HtmlUnitDriver.java:458)
at ATest.main(ATest.java:46)