List of usage examples for org.openqa.selenium.remote RemoteWebDriver getCommandExecutor
public CommandExecutor getCommandExecutor()
From source file:com.vaadin.testbench.commands.TestBenchCommandExecutor.java
@Override public String getRemoteControlName() { InetAddress ia = null;/* w w w.ja v a 2s. co m*/ try { if (actualDriver instanceof RemoteWebDriver) { RemoteWebDriver rwd = (RemoteWebDriver) actualDriver; if (rwd.getCommandExecutor() instanceof HttpCommandExecutor) { ia = InetAddress.getByName( ((HttpCommandExecutor) rwd.getCommandExecutor()).getAddressOfRemoteServer().getHost()); } } else { ia = InetAddress.getLocalHost(); } } catch (UnknownHostException e) { getLogger().log(Level.WARNING, "Could not find name of remote control", e); return "unknown"; } if (ia != null) { return String.format("%s (%s)", ia.getCanonicalHostName(), ia.getHostAddress()); } return null; }
From source file:com.vaadin.tests.elements.AbstractTB3Test.java
License:Apache License
protected String getRemoteControlName() { try {//from w w w.ja v a 2 s . c o m RemoteWebDriver d = getRemoteDriver(); if (d == null) { return null; } HttpCommandExecutor ce = (HttpCommandExecutor) d.getCommandExecutor(); String hostName = ce.getAddressOfRemoteServer().getHost(); int port = ce.getAddressOfRemoteServer().getPort(); HttpHost host = new HttpHost(hostName, port); DefaultHttpClient client = new DefaultHttpClient(); URL sessionURL = new URL( "http://" + hostName + ":" + port + "/grid/api/testsession?session=" + d.getSessionId()); BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", sessionURL.toExternalForm()); HttpResponse response = client.execute(host, r); JsonObject object = extractObject(response); URL myURL = new URL(object.get("proxyId").getAsString()); if ((myURL.getHost() != null) && (myURL.getPort() != -1)) { return myURL.getHost(); } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusableRemoteWebDriver.java
License:Apache License
private ReusableRemoteWebDriver(RemoteWebDriver remoteWebDriver) { super();/* w w w. j a v a 2 s . c o m*/ setCommandExecutor(remoteWebDriver.getCommandExecutor()); reuseSession(remoteWebDriver.getSessionId(), remoteWebDriver.getCapabilities()); try { checkReusability(); } catch (UnableReuseSessionException e) { throw new IllegalStateException("Reusing RemoteWebDriver session unexpectedly failed", e); } }