Problems launching Google Chrome using WebDriver

2,437 views
Skip to first unread message

Mike Riley

unread,
Mar 20, 2012, 2:02:37 PM3/20/12
to Selenium Users
All of my test sessions with Chrome seem to work fine, except for my
very last one. The code to start the session is a library routine, so
there should be no difference in how it gets started, yet the last one
fails every time.

I am using the latest chromedriver.exe with 2.14.0, but I had this
same problem on the last chromedriver.exe version, and I think even
with the one before that, so this is not a regression per se.

Here is what I get on my console output.

Trying to start test session with: Capabilities [{platform=ANY,
browserName=chrome, chrome.switches=[--ignore-certificate-errors],
version=}]
Unable to create Selenium session.
org.openqa.selenium.WebDriverException: Error communicating with the
remote browser. It may have died. Build info: version: '2.14.0',
revision: '14955', time: '2011-11-29 11:43:45' System info: os.name:
'Windows Vista', os.arch: 'x86', os.version: '6.0', java.version:
'1.6.0_31' Driver info: driver.version: RemoteWebDriver at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:
396) at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:
115) at org.openqa.selenium.remote.RemoteWebDriver.
(RemoteWebDriver.java:76) at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:84)
at dotn_helper.DOTN_Helper.(DOTN_Helper.java:378) at ...

Here is what I am seeing in the chromedriver.log file:

[0.016][INFO]: ChromeDriver 19.0.1068.0 V:\QA\Selenium
\chromedriver.exe
[0.297][FINE]: Initializing session with capabilities {
"browserName": "chrome",
"chrome.switches": [ "--ignore-certificate-errors" ],
"platform": "ANY",
"version": ""
}

[0.922][INFO]: Launching chrome: "C:\Users\mriley\AppData\Local
\Google\Chrome\Application\chrome.exe" --disable-hang-monitor --
disable-prompt-on-repost --dom-automation --full-memory-crash-report --
no-default-browser-check --no-first-run --ignore-certificate-errors --
homepage=about:blank --ignore-certificate-errors
[49.735][SEVERE]: Failed to initialize connection

Any suggestions as to how to better diagnose why this one invocation
(I currently run 4 test suites and only this last one fails) is
failing? Maybe I need to provide an additional switch in my
capabilities configuration, or maybe there is a way to turn on some
more verbose diagnostics that could help figure out what is going
wrong here.

Here is the line in DOTN_Helper that is getting the error:
driver = new RemoteWebDriver(new URL("http://" + host + ":" +
port +
"/wd/hub"), capability);

The remote server is registered with the Grid hub and that is what the
RemoteWebDriver talks to.

Thanks.

Mike Riley

Rajat Jindal

unread,
Mar 21, 2012, 12:11:52 PM3/21/12
to seleniu...@googlegroups.com
Not so quite sure, but it looks like the problem with the code that you have written. [Is your webdriver object getting destroyed somehow before you expect it to get destroyed?] I am running sequential tests using webdriver + Chrome daily and never faced such an issue. 

If you can provide some insight on how your test suites are designed, we can offer better help.

Thanks
Rajat Jindal

Mike Riley

unread,
Mar 21, 2012, 1:52:19 PM3/21/12
to Selenium Users
Last night that suite ran fine with Chrome, but the suite before it
had the same problem. Since it is failing at the call to create the
RemoteWebDriver instance, I can't see how it can be destroyed, because
it hasn't yet been created! #8^(

This same code is working for 4 different version of IE and four
different versions of FF, and mostly works for Chrome too. Just every
so often it has this failure where it does not create the
RemoteWebDriver object. Based on what I see in the log file it seems
I don't need to set the --ignore-certificate-errors in the
capabilities object that I pass, because it is now the default. I am
not sure if having it defined twice would cause a problem.

Here is the code for the method that starts the task:

public DOTN_Helper(TestParameters testParameters) throws Exception
{
String str;
org.openqa.selenium.remote.DesiredCapabilities capability;
String[] chromeSwitches =
{
"--ignore-certificate-errors"
};
FirefoxProfile ffProfile;

setTestParams(testParameters);
testNG = testParameters.testNG;

switch (Parser.findString(browserName, BROWSERS))
{
case 0:
capability = DesiredCapabilities.firefox();
str = "Firefox" + browserVersion + ".profile";
ffProfile = new FirefoxProfile(new File(str));
capability.setCapability(FirefoxDriver.PROFILE,
ffProfile);
browser = FIREFOX;
break;
case 1:
capability = DesiredCapabilities.internetExplorer();
browser = INTERNET_EXPLORER;
break;
case 2:
capability = DesiredCapabilities.chrome();
capability.setCapability("chrome.switches",

Arrays.asList(chromeSwitches));
//capability.setCapability("chrome.binary",
// "C:\\Program Files\\Google\\Google Chrome\
\chrome.exe");
browser = CHROME;
break;
case 3:
capability = DesiredCapabilities.htmlUnit();
capability.setJavascriptEnabled(true); // Off by
default for htmlUnit
browser = HTML_UNIT;
break;
case 4:
capability = DesiredCapabilities.opera();
capability.setCapability("opera.logging.level",
"FINE");
browser = OPERA;
break;
default:
throw new Exception("Unknown browser name for
RemoteWebDriver: " +
browserName + ".");
} // switch

if (platform.equalsIgnoreCase("WINDOWS") ||
browserName.equals(
"*iexplore"))
capability.setPlatform(Platform.WINDOWS);
else
capability.setPlatform(Platform.ANY);

capability.setVersion(browserVersion);
Reporter.log("Trying to start test session with: " +
capability.toString(), true);
driver = new RemoteWebDriver(new URL("http://" + host + ":" +
port +
"/wd/hub"), capability);
try
{ // We have a session started, don't leave it as an orphan
now
str = "Information from navigator object in browser:" +
"\nuserAgent: " +
driver.executeScript("return
window.navigator.userAgent") +
"\nappCodeName: " +
driver.executeScript("return
window.navigator.appCodeName") +
"\nappVersion: " +
driver.executeScript("return
window.navigator.appVersion") +
"\nlanguage: " +
driver.executeScript("return
window.navigator.language") +
"\nplatform: " +
driver.executeScript("return
window.navigator.platform") +
"\n";
System.out.print(str);
str = str.replace("\n", "<br />");
Reporter.log(str);
selenium = new WebDriverBackedSelenium(driver,
baseUrlString);
selenium.open(baseUrlString);
} // try
catch (Exception ex)
{ // We had an exception after creating the WebDriver
instance
tearDown(); // Make sure we close the browser down
throw ex; // Now report the exception
} // catch
} // DOTN_Helper */

The testParameters you see there are the command line switches that
were passed when the test suite was invoked. Everything else is
pretty self-explanatory.

I think that to figure this out I need to turn on some more detailed
diagnostics. So I would like to know how to do that. Remember, this
is running unattended at about 1:00AM, so any issue like this I pretty
much need to trap some debug output to catch it in the act.

Mike

On Mar 21, 9:11 am, Rajat Jindal <rajatjinda...@gmail.com> wrote:
> Not so quite sure, but it looks like the problem with the code that you
> have written. [Is your webdriver object getting destroyed somehow before
> you expect it to get destroyed?] I am running sequential tests using
> webdriver + Chrome daily and never faced such an issue.
>
> If you can provide some insight on how your test suites are designed, we
> can offer better help.
>
> Thanks
> Rajat Jindalhttp://www.quicksilver1183.com

Selenium User

unread,
Apr 9, 2013, 5:15:27 AM4/9/13
to seleniu...@googlegroups.com
Hi Mike,

I am facing issue running my Grid 2 test cases for Chrome and IE browser. They give the same exception given below.I am sure I am missing a very trivial thing but I am not able to figure it out. 
    
    Please see my grid batch file. (I added both chrome binary and chrome driver location in my path)

My code works perfectly if I use firefox but for chrome and IE it throws an Exception given below. 

Here is my Batch file
    
    set HERE=C:\Users\Administrator\Downloads
    set JAVA_HOME=%HERE%\jdk-7u13-windows-x64
    set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%CHROME_DRIVER_LOC%;%IE_DRIVER_LOC%;%CHROME_BINARY_LOC%;%PATH%;
    set SELENIUM_VERSION=2.29.0
    set CHROME_VERSION=chromedriver_win_26.0.1383.0
    set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0\chromedriver.exe
    set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe
    set CHROME_BINARY_LOC=C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe
    start java -jar selenium-server-standalone-2.29.0.jar -role hub
    start java -jar selenium-server-standalone-2.29.0.jar -role node
    -Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556
    
    My sample code:
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
    URL url = new URL(“http://localhost:4444/wd/hub”);
    WebDriver driver = new RemoteWebDriver(url, capabilities);
    
    // And now use this to visit Google
    driver.get(“http://www.google.com”);
    
    Exception I am getting :
    
    Exception in thread “main” org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
    Command duration or timeout: 608 milliseconds
    Build info: version: ’2.29.0′, revision: ’58258c3′, time: ’2013-01-17 22:47:00′
    System info: os.name: ‘Windows Server 2008 R2′, os.arch: ‘amd64′, os.version: ’6.1′, java.version: ’1.7.0_13′
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129)
    at test.Test.main(Test.java:32)
    Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see ….
    
 
   Please help! I couldn't understand what I am doing wrong. I have been struggling with this from quite some time now. Any help will be very much appreciated.
    
    Thanks
    Sushmita

Krishnan Mahadevan

unread,
Apr 9, 2013, 5:26:23 AM4/9/13
to Selenium Users
There are a couple of bugs in your batch file to begin with.

I made some changes to it. Give it a try and let me know how it goes.

set HERE=C:\Users\Administrator\Downloads
set JAVA_HOME=%HERE%\jdk-7u13-windows-x64
set SELENIUM_VERSION=2.29.0
set CHROME_VERSION=chromedriver_win_26.0.1383.0
set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0\chromedriver.exe
set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe
set CHROME_BINARY_LOC=C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe
set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%CHROME_DRIVER_LOC%;%IE_DRIVER_LOC%;%CHROME_BINARY_LOC%;%PATH%;
start java -jar selenium-server-standalone-2.29.0.jar -role hub
start java -jar selenium-server-standalone-2.29.0.jar -role node -hub %HUB_URL% -port 5556

Explanation:
You were setting the PATH variable much before the variables CHROME_DRIVER_LOC, IE_DRIVER_LOC and CHROME_BINARY_LOC were even being defined. I moved it to the last part.

I think that with the newer versions of Selenium, you DONT explicitly need to use the -D VM arg. Merely ensuring that the location of these binaries is appended to the PATH environment variable should suffice.

Give it a shot. This should help !





Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/F8A8XBdNvi8J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Selenium User

unread,
Apr 9, 2013, 6:49:02 AM4/9/13
to seleniu...@googlegroups.com
Hi Krishnan

I updated my batch file but still same Exception.

If I use chrome Driver instead of RemoteWebDriver, it works.

Krishnan Mahadevan

unread,
Apr 9, 2013, 7:13:34 AM4/9/13
to Selenium Users
Am a bit confused here.

Where exactly is your Grid and node running ?

If the node and your test code (say eclipse is what you are using to run your tests) running out of the same machine ?


Make sure that the binaries are available in the node machine as well.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Hjz52CJoPeYJ.

Selenium User

unread,
Apr 9, 2013, 7:51:56 AM4/9/13
to seleniu...@googlegroups.com
The Grid and Node are running on same machine and even my test code is on the same machine.

Krishnan Mahadevan

unread,
Apr 9, 2013, 8:10:21 AM4/9/13
to Selenium Users
This is getting tricky by the hour.Can you please do the following and check if you are manually able to invoke the chromedriver and IEDriverServer.exe binaries ?

Manually update the PATH variable with the location of these binaries and then try to invoke them from the command prompt [cross check in the task manager if they are present there or not]

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/8vVDS6SIaaQJ.

Selenium User

unread,
Apr 9, 2013, 9:50:05 AM4/9/13
to seleniu...@googlegroups.com
Hi 

I manually updated the PATH variables and I am able to run the chromedriver.exe and IEDriverServer.exe from Command Prompt. I checked with task manager and they are running fine. Please see screenshot.

In batch file I gave parameter -port 5556 and when running binaries it says, 
For Internet Explorer : Listening to port 5555
For Chome: port 9515

I am not sure if this is the reason but just want to bring that in notice.

Thanks for helping me.
chrome.png

Krishnan Mahadevan

unread,
Apr 9, 2013, 9:51:44 AM4/9/13
to Selenium Users
You ran it from the directory where they are available. I wanted you to just open up a command prompt and try running them [without switching to the directory where they exist ]

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/SyrjXlj6DcEJ.

Krishnan Mahadevan

unread,
Apr 9, 2013, 9:54:02 AM4/9/13
to Selenium Users
Also try changing the following in your batch file and re-attempt your test 

Change
set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0\chromedriver.exe
set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe

to

set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0
set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0


You should be setting the directories to where these binaries exist into your PATH environment variable AND NOT APPEND the actual exe's name by itself.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


Selenium User

unread,
Apr 9, 2013, 10:19:58 AM4/9/13
to seleniu...@googlegroups.com
Thank you so so much Krishnan.

It worked. Chrome worked correctly. For IE, the browser gets started but then it is not able to locate elements.

But anyway you solved a LOT bigger trouble for me.

Thanks once again.

Krishnan Mahadevan

unread,
Apr 9, 2013, 10:34:23 AM4/9/13
to Selenium Users
Phew! Finally your issue is resolved :) Glad you got around it !

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/gSk_owbxZvAJ.

Selenium User

unread,
Apr 9, 2013, 10:37:40 AM4/9/13
to seleniu...@googlegroups.com
Each and every bit of it to you. 

Firstly learning to do configuration from your post http://www. rationaleemotions.wordpress.com/2012/01/23/setting-up-grid2-and-working-with-it/  and then now.

Couldn't thank you enough.
Reply all
Reply to author
Forward
0 new messages