Unable to use Selenium Backed Webdriver with Chrome

204 views
Skip to first unread message

cuvien

unread,
Jul 12, 2011, 6:22:50 PM7/12/11
to webdriver
The application I'm testing needs to be tied to Chrome 11.x so i
cannot use the latest Chrome WebDriver. I tried to use the recommended
method of using the Selenium backed WebDriver. However, I get an
exception when starting the browser. The same code works well with
Firefox.

Unable to use Selenium Backed Webdriver with Chrome

Build Server: selenium-server-standalone-2.0.0.jar
Build Client: selenium-java-2.0rc3.jar
OS: Win7
Browser: Chrome 12.x

Steps:
1. Launch server
2. Run following snippet
{{{
Capabilities capabilities = DesiredCapabilities.chrome();
CommandExecutor executor = new SeleneseCommandExecutor(new URL("http://
localhost:4444/"), new URL("http://www.google.com/"), capabilities);
WebDriver driver = new RemoteWebDriver(executor, capabilities);
}}}

Result:
On client gets:
org.openqa.selenium.WebDriverException: Could not start Selenium
session: Failed to start new browser session: Error while launching
browser

On server gets:
15:12:57.961 INFO [22]
org.openqa.selenium.server.SeleniumDriverResourceHandler - Command
request: getNewBrowserSession[*googlechrome /Applications/Google
Chrome.app/Contents/MacOS/Google Chrome, http://www.google.com/, ,
platform=ANY;browserName=chrome;version=] on session null
15:12:57.964 INFO [22]
org.openqa.selenium.server.BrowserSessionFactory - creating new remote
session
15:12:57.968 DEBUG [22]
org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory -
Requested browser string '*googlechrome /Applications/Google
Chrome.app/Contents/MacOS/Google Chrome' matches *googlechrome
15:12:57.968 DEBUG [22]
org.openqa.selenium.browserlaunchers.locators.BrowserLocator -
Checking whether Google Chrome launcher at :'\Applications\Google
Chrome.app\Contents\MacOS\Google Chrome' is valid...
15:12:57.968 INFO [22]
org.openqa.selenium.server.BrowserSessionFactory - Allocated session
3bac0e3775244973b9aef70e927961d9 for http://www.google.com/,
launching...
15:12:57.969 INFO [22]
org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher -
Launching Google Chrome...
15:12:57.997 ERROR [22]
org.openqa.selenium.server.BrowserSessionFactory - Failed to start new
browser session, shutdown browser and clear all session data
java.lang.NullPointerException
at
org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher.createCommandArray(GoogleChromeLauncher.java:
166)
at
org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher.launch(GoogleChromeLauncher.java:
77)
at
org.openqa.selenium.server.browserlaunchers.AbstractBrowserLauncher.launchRemoteSession(AbstractBrowserLauncher.java:
37)
at
org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:
375)
at
org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:
125)
at
org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:
87)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:
785)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:
422)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:
393)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:
146)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:
820)
at
org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:
986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:
837)
at
org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:
243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:
357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:
534)
15:12:58.019 INFO [22]
org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher -
Killing Google Chrome...
15:12:58.022 DEBUG [22]
org.openqa.selenium.server.FrameGroupCommandQueueSet - clearing queue
set
15:12:58.022 INFO [22]
org.openqa.selenium.server.SeleniumDriverResourceHandler - Got result:
Failed to start new browser session: Error while launching browser on
session null
15:12:58.023 DEBUG [22] org.openqa.jetty.http.HttpContext - Handled by
org.openqa.selenium.server.SeleniumDriverResourceHandler in
HttpContext[/selenium-server,/selenium-server]
15:12:58.025 DEBUG [22] org.openqa.jetty.http.HttpConnection -
RESPONSE:
HTTP/1.1 200 OK
Date: Tue, 12 Jul 2011 22:12:57 GMT
Server: Jetty/5.1.x (Windows 7/6.1 amd64 java/1.6.0_24
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 66

Simon Stewart

unread,
Jul 14, 2011, 9:35:03 AM7/14/11
to webd...@googlegroups.com
How are you planning on preventing Chrome from auto-updating? If you
can, stick to Chrome 12, which has better support for webdriver.

Also, from your code, you're not using the new chrome driver. That
would look like a straight call to "new ChromeDriver()" You've
currently configured everything to go through the original Selenium
server.

The recommended approach to migrate from Selenium RC to the WebDriver
API looks like:

WebDriver driver = new ChromeDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);

You can then use your existing tests without rewriting, but can break
out the WebDriver instance easily using:

((WrapsDriver) selenium).getWrappedDriver();

Allowing you to migrate the code in a piecemeal fashion.

Simon

> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>
>

cuvien

unread,
Jul 14, 2011, 12:36:18 PM7/14/11
to webdriver
Thanks Simon for taking the time out to answer my question (and all
your work on WebDriver:)

The product i'm testing is a custom Chromium with a very specific
plugin. Update is disabled. However, for the most part, it works like
Chrome, except for a few tags and classes under test. We are
rebuilding Chromium from source and updating to latest code base not
in scope right now.

I really like the WebDriver API so I'm trying to use it as described
here (Testing earlier versions of Chrome, http://code.google.com/p/selenium/wiki/ChromeDriver).
This way, once we update to the latest Chromium code base, I can
retain the existing tests and just switch to the new driver. So using
the Selenium backed WebDriver is intentional.

Do you think there an issue in the RemoteWebDriver when working with
Selenium Server 2.0? If so, do you know where I can fix it?
Reply all
Reply to author
Forward
0 new messages