So I have been trying to use RemoteWebDriver instead of instantiating
InternetExplorerDriver directly. I want the tests to run on the
machine that holds the jar file containing the tests, so I am trying
to establish a RemoteWebDriver on localhost. I have made several
attempts, but the constructors keep throwing various Exceptions:
I get an UnsupportedCommandException when I run the following code
System.out.println("Instantiating Internet Explorer RemoteWebDriver");
DesiredCapabilities capabilities =
DesiredCapabilities.internetExplorer();
capabilities.setJavascriptEnabled(true);
try {
AppServer server = new AppServer();
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://
localhost/"), capabilities);
System.out.println("Instantiation complete");
}
...
with AppServer defined as:
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.webapp.WebAppContext;
import java.io.File;
public class AppServer {
private Server server = new Server();
public AppServer() throws Exception {
WebAppContext context = new WebAppContext();
context.setContextPath("");
context.setWar((new File(".")).getAbsolutePath());
server.setHandler(context.getHandler());
context.addServlet(DriverServlet.class, "/wd/*");
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(3001);
server.addConnector(connector);
server.start();
}
}
The resulting error is:
org.openqa.selenium.UnsupportedCommandException: <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /session was not found on this server.</p>
</body></html>
Do I need to create a handler for /session? What would it need to do?
If DriverServlet is supposed to be handling this kind of request, what
could be preventing this? The code that the AppServer is based off of
was using the mortbay version of jetty. Because I have the eclipse
libraries, some of the imports were different. The original code used
addHandler(), but in the eclipse version their seems to be only
setHandler(), could this be preventing the handler from being used
properly?
If I do not include the URL in the RemoteWebDriver constructor, I get
a MalformedURLException.
I have tried using InternetExplorerDriverServer, but I cannot actually
start the server:
System.out.println("Instantiating Internet Explorer RemoteWebDriver");
DesiredCapabilities capabilities =
DesiredCapabilities.internetExplorer();
capabilities.setJavascriptEnabled(true);
try {
InternetExplorerDriverServer IEDS = new
InternetExplorerDriverServer(80);
IEDS.start();
Thread.sleep(3000);
System.out.println("Getting URL");
System.out.println(IEDS.getUrl());
System.out.println("got URL");
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://
localhost/"), capabilities);
System.out.println("Instantiation complete");
return driver;
}
...
The result I get is:
Instantiating Internet Explorer RemoteWebDriver
Getting URL
org.openqa.selenium.WebDriverException: Server has not yet been
started
Is port 80 correct/adequate? If I remove the getUrl() call, then I see
the same UnsupportedCommandException as before.
On Jul 16, 5:35 am, Jim Evans <
james.h.evans...@gmail.com> wrote:
> If you're looking at sources from 2.0a2, you're looking at sources
> that are extremely out of date. Latest sources can always be found athttp://
selenium.googlecode.com/svn/trunk. In point of fact, the C++