Apache Nutch is an extensible and scalable web crawler
Fix for NUTCH-2096: Explicitly indicate broswer binary to use when selecting selenium remote option in config contributed by Kim Whitehall <[email protected]> this closes #56.
Chris Mattmann49dae14e682b
diff --git a/CHANGES.txt b/CHANGES.txtindex be89d638e..14adbae4a 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,9 @@ Nutch Change LogNutch Current Development 1.11-SNAPSHOT+* NUTCH-2096 Explicitly indicate broswer binary to use when selecting+ selenium remote option in config (Kim Whitehall via mattmann)+* NUTCH-2090 Refactor Seed Resource in REST API (Sujen Shahvia mattmann)diff --git a/conf/nutch-default.xml b/conf/nutch-default.xmlindex f98547e1b..cbd2a55b9 100644--- a/conf/nutch-default.xml+++ b/conf/nutch-default.xml@@ -1787,8 +1787,8 @@ CAUTION: Set the parser.timeout to -1 or a bigger value than 30, when using thisWebDriver() to use. Currently the following optionsexist - 'firefox', 'chrome', 'safari', 'opera' and 'remote'.If 'remote' is used it is essential to also set correct properties for- 'selenium.hub.port', 'selenium.hub.path', 'selenium.hub.host' and- 'selenium.hub.protocol'.+ 'selenium.hub.port', 'selenium.hub.path', 'selenium.hub.host',+ 'selenium.hub.protocol', 'selenium.grid.driver' and 'selenium.grid.binary'.</description></property>@@ -1840,6 +1840,22 @@ CAUTION: Set the parser.timeout to -1 or a bigger value than 30, when using this<description>Selenium Hub Location connection protocol</description></property>+<property>+ <name>selenium.grid.driver</name>+ <value>firefox</value>+ <description>A String value representing the flavour of Selenium+ WebDriver() used on the selenium grid. Currently the following options+ exist - 'firefox' </description>+</property>++<property>+ <name>selenium.grid.binary</name>+ <value></value>+ <description>A String value representing the path to the browser binary+ location for each node+ </description>+</property>+<!-- lib-selenium configuration --><property><name>libselenium.page.load.delay</name>diff --git a/src/plugin/lib-selenium/src/java/org/apache/nutch/protocol/selenium/HttpWebClient.java b/src/plugin/lib-selenium/src/java/org/apache/nutch/protocol/selenium/HttpWebClient.javaindex ab3cd9b0b..8cd670186 100644--- a/src/plugin/lib-selenium/src/java/org/apache/nutch/protocol/selenium/HttpWebClient.java+++ b/src/plugin/lib-selenium/src/java/org/apache/nutch/protocol/selenium/HttpWebClient.java@@ -64,6 +64,7 @@ public class HttpWebClient {public static WebDriver getDriverForPage(String url, Configuration conf) {WebDriver driver = null;+ DesiredCapabilities capabilities = null;long pageLoadWait = conf.getLong("libselenium.page.load.delay", 3);try {@@ -86,8 +87,22 @@ public class HttpWebClient {int seleniumHubPort = Integer.parseInt(conf.get("selenium.hub.port", "4444"));String seleniumHubPath = conf.get("selenium.hub.path", "/wd/hub");String seleniumHubProtocol = conf.get("selenium.hub.protocol", "http");- driver = new RemoteWebDriver(new URL(seleniumHubProtocol, seleniumHubHost, seleniumHubPort, seleniumHubPath), DesiredCapabilities.firefox());- break;+ String seleniumGridDriver = conf.get("selenium.grid.driver","firefox");+ String seleniumGridBinary = conf.get("selenium.grid.binary");++ switch (seleniumGridDriver){+ case "firefox":+ capabilities = DesiredCapabilities.firefox();+ capabilities.setBrowserName("firefox");+ capabilities.setJavascriptEnabled(true);+ capabilities.setCapability("firefox_binary",seleniumGridBinary);+ driver = new RemoteWebDriver(new URL(seleniumHubProtocol, seleniumHubHost, seleniumHubPort, seleniumHubPath), capabilities);+ break;+ default:+ LOG.error("The Selenium Grid WebDriver choice {} is not available... defaulting to FirefoxDriver().", driverType);+ driver = new RemoteWebDriver(new URL(seleniumHubProtocol, seleniumHubHost, seleniumHubPort, seleniumHubPath), DesiredCapabilities.firefox());+ break;+ }default:LOG.error("The Selenium WebDriver choice {} is not available... defaulting to FirefoxDriver().", driverType);driver = new FirefoxDriver();