Skip to content

Commit

Permalink
Allow the Grid Hub and StandaloneServer to use the new WebDriverServlet
Browse files Browse the repository at this point in the history
With this enabled, it's possible to establish an
end-to-end w3c session, even when using grid. To
enable it, start the hub server with the flag
`-enablePassThrough`

Once this is done, it should be possible to use
the new Actions API with a session.
  • Loading branch information
shs96c committed May 21, 2017
1 parent 5d13839 commit b9f0349
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions java/server/src/org/openqa/grid/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ java_library(name = 'grid',
'//java/client/src/org/openqa/selenium:selenium',
'//java/client/src/org/openqa/selenium/remote:remote',
'//java/server/src/org/openqa/selenium/remote/server:server',
'//java/server/src/org/openqa/selenium/remote/server:webdriver-servlet',
'//java/server/src/org/openqa/selenium/remote/server/log:log',
'//third_party/java/beust:jcommander',
'//third_party/java/gson:gson',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,10 @@ private void fixUpCapabilities() {
}

private void fixUpHost() {
NetworkUtils util = new NetworkUtils();
if (configuration.host == null || "ip".equalsIgnoreCase(configuration.host)) {
NetworkUtils util = new NetworkUtils();
configuration.host = util.getIp4NonLoopbackAddressOfThisMachine().getHostAddress();
} else if ("host".equalsIgnoreCase(configuration.host)) {
NetworkUtils util = new NetworkUtils();
configuration.host = util.getIp4NonLoopbackAddressOfThisMachine().getHostName();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ public class StandaloneConfiguration {
)
public Integer timeout = DEFAULT_TIMEOUT;

@Expose
@Parameter(
names = "-enablePassThrough",
description = "<Boolean>: Whether or not to use the experimental passthrough mode. Defaults to false."
)
public boolean newHandler = false;


/**
* Creates a new configuration using the default values.
*/
Expand Down
12 changes: 10 additions & 2 deletions java/server/src/org/openqa/grid/web/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.openqa.grid.web.servlet.beta.ConsoleServlet;
import org.openqa.grid.web.utils.ExtraServletUtil;
import org.openqa.selenium.net.NetworkUtils;
import org.openqa.selenium.remote.server.WebDriverServlet;
import org.seleniumhq.jetty9.server.HttpConfiguration;
import org.seleniumhq.jetty9.server.HttpConnectionFactory;
import org.seleniumhq.jetty9.server.Server;
Expand Down Expand Up @@ -103,8 +104,15 @@ private void addDefaultServlets(ServletContextHandler handler) {
// add mandatory default servlets
handler.addServlet(RegistrationServlet.class.getName(), "/grid/register/*");

handler.addServlet(DriverServlet.class.getName(), "/wd/hub/*");
handler.addServlet(DriverServlet.class.getName(), "/selenium-server/driver/*");
if (config.newHandler) {
log.info("Using the experimental passthrough mode");
handler.addServlet(DriverServlet.class.getName(), "/wd/hub/*");
handler.addServlet(DriverServlet.class.getName(), "/selenium-server/driver/*");
} else {
handler.addServlet(WebDriverServlet.class.getName(), "/wd/hub/*");
handler.addServlet(WebDriverServlet.class.getName(), "/selenium-server/driver/*");
}


handler.addServlet(ProxyStatusServlet.class.getName(), "/grid/api/proxy/*");

Expand Down
1 change: 1 addition & 0 deletions java/server/src/org/openqa/selenium/remote/server/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ java_library(
'//third_party/java/guava:guava',
],
visibility = [
'//java/server/src/org/openqa/grid:grid',
'//java/server/test/org/openqa/selenium/remote/server:tests',
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.seleniumhq.jetty9.util.thread.QueuedThreadPool;

import java.util.Map;
import java.util.logging.Logger;

import javax.servlet.Servlet;

Expand All @@ -43,6 +44,8 @@
*/
public class SeleniumServer implements GridNodeServer {

private final static Logger LOG = Logger.getLogger(SeleniumServer.class.getName());

private Server server;
private DefaultDriverSessions driverSessions;
private StandaloneConfiguration configuration;
Expand Down Expand Up @@ -125,8 +128,14 @@ public void boot() {
new SystemClock());
handler.setAttribute(DriverServlet.SESSIONS_KEY, driverSessions);
handler.setContextPath("/");
handler.addServlet(DriverServlet.class, "/wd/hub/*");
handler.addServlet(WebDriverServlet.class, "/webdriver/*");
if (configuration.newHandler) {
LOG.info("Using the experimental passthrough mode handler");
handler.addServlet(WebDriverServlet.class, "/wd/hub/*");
handler.addServlet(WebDriverServlet.class, "/webdriver/*");
} else {
handler.addServlet(DriverServlet.class, "/wd/hub/*");
handler.addServlet(DriverServlet.class, "/webdriver/*");
}
handler.setInitParameter(ConsoleServlet.CONSOLE_PATH_PARAMETER, "/wd/hub");

handler.setInitParameter(DisplayHelpServlet.HELPER_TYPE_PARAMETER, configuration.role);
Expand Down

0 comments on commit b9f0349

Please sign in to comment.