Wednesday, February 11, 2009

How to make Selenium use Google Chrome

Google's Chrome web browser was released in September of 2008, and is an increasingly popular browser to use for testing using Selenium. The RC was patched on the day that the web browser was released with a new browser launcher for Chrome. You'll need revision 2408 or later. There is nothing special that one must do to start a Selenium session using Chrome. All you need to do is call the Selenium constructor with the browser type argument of "*googlechrome".

For example:

from selenium import selenium
s = selenium("localhost", "4444", "*googlechrome", "http://www.google.com")
s.start()

Current Bugs:
  • There have been reports that Chrome support for selenium won't work on Windows XP 64-bit.
  • The Google Chrome launcher does not support the avoidProxy option (SRC-524)
  • http://localhost doesn't work as a starting URL in Google Chrome (SRC-529)

3 comments:

Unknown said...

Hello,

Would like to add another bug to the list:

Selenium.Open() using Google Chrome throws exception (SRC-740)

Seems like Selenium RC needs to start Chrome in privileged mode. The bug was fixed but for now it is only available in the Selenium trunk.

Unknown said...

I get the following error. The RC node is on Windows XP Pro (32-bit). The selenium grid hub is on MS Windows Server 2003 R2 Enterprise. When you said there have been reports of this not working on 64-bits did you mean both ends or just the RC end?

Selenium.SeleniumException: XHR ERROR: URL = http://www.google.com Response_Code = 400 Error_Message = Bad Request

It doesn't matter what URL I give it ... whether it ends in a / or .html or a directory name or a host name.

Samuel A. Falvo II said...

Unfortunately, this is not sufficient to get Selenium working together with Google Chrome under the MacOS environment. As I type this, I do not know how to integrate the two. If anyone has any ideas, please post them below. Thanks!!