ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Unable to either launch or connect to Chrome exception when running chromedriver tests from MSBuild #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From http://code.google.com/p/chromium/issues/detail?id=91340

Chrome Version    12.0.742.122   : I have also tried 14.0.835.15 dev-m
Chromedriver version chromedriver_win32_14.0.836.0.zip
OS: Windows Server 2008
Issue occur with all WebDriver versions up to the latest V2.3

Other browsers tested:
  Firefox and IE works.
issue:

We have a MSBuild setup that starts MSTests and excecutes a battery of various 
tests. Executing Firefox and IE tests with InternetExplorerDriver and 
FirefoxDriver works fine. Starting Chrome tests fails with following error 
messages.

Chromedriver log:
Started ChromeDriver
port=50938
version=14.0.836.0
[0802/110912:ERROR:proxy_launcher.cc(96)] WaitForInitialLoads failed.

TestResultLog

Error Message:
Test method SeleniumTests.ChromeDriverIssueTest.ChromeDriverTest threw 
exception: 
System.Reflection.TargetInvocationException: Exception has been thrown by the 
target of an invocation. ---> System.InvalidOperationException: Unable to 
either launch or connect to Chrome. Please check that ChromeDriver is 
up-to-date. Using Chrome binary at: 
C:\Users\roberth\AppData\Local\Google\Chrome\Application\chrome.exe

StackTrace
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response 
errorResponse) in 
c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs: 
line 958
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand 
driverCommandToExecute, Dictionary`2 parameters) in 
c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs: 
line 805
OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities 
desiredCapabilities) in 
c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs: 
line 773
OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, 
ICapabilities desiredCapabilities) in 
c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs: 
line 81
OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, 
ICapabilities capabilities, TimeSpan commandTimeout) in 
c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Chrome\ChromeDriver.cs: line 
121
OpenQA.Selenium.Chrome.ChromeDriver..ctor() in 
c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Chrome\ChromeDriver.cs: line 71
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, 
Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, 
Boolean& bNeedSecurityCheck)
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean 
skipCheckThis, Boolean fillCache)
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean 
skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
System.Activator.CreateInstance[T]()
CodedUITests.Framework.TestBases.WebDriversTestBase.GetWebDriver[T](String url) 
in 
D:\Dev\CrossBrowser\TestCode\CodedUITests\CodedUITests.Framework\TestBases\WebDr
iversTestBase.cs: line 43
SeleniumTests.ChromeDriverIssueTest.ChromeDriverTest() in 
D:\Dev\CrossBrowser\TestCode\CodedUITests\CodedUITests\SurveyEngine\TempChromeTe
st.cs: line 129

What steps will reproduce the problem?
1. Setup an MSBuild that starts an MSTest process that executes any 
chromedriver test.
2.
3.

What is the expected result?
Chrome should be opened and the tests executed

What happens instead?
Chromedriver and Chrome starts but nothing more happens. Chrome opens the 
about:blank page and says Loading... after about ~20 seconds Chrome is closed 
and the error message in chromedriver described above is visible.

Please provide any additional information below. Attach a screenshot if
possible.

If you execute the tests directly with MSTest instead of using MSBuild 
everything works fine with ChromeDriver.

Original issue reported on code.google.com by kkania@chromium.org on 5 Mar 2012 at 10:11

GoogleCodeExporter commented 9 years ago
Can you still reproduce this? If so, can I have some instructions on setting up 
a msbuild project (preferably attach a small demo project with instructions for 
reproducing your problem)?

Original comment by kkania@chromium.org on 5 Mar 2012 at 10:13

GoogleCodeExporter commented 9 years ago
Issue chromium:91340 has been merged into this issue.

Original comment by kkania@chromium.org on 5 Mar 2012 at 10:13

GoogleCodeExporter commented 9 years ago
I do not work at the company where we had this issue anymore. But I think this 
is still an issue. I have contacted my former colleges and they will try to set 
something up.

Original comment by proffsro...@gmail.com on 7 Mar 2012 at 7:06

GoogleCodeExporter commented 9 years ago
Hi,

Hope the following will shed some light on the issue:

The problem is related to the use of TestToolsTask (wrapper task for running 
tests that comes with Visual Studio Team Build). The attached project with 
MSBuild project uses 

Running mstest directly works:

msbuild Test.proj /t:RunTestsWithMSTestDirectly

But running the tests using TestToolsTask somehow meeses up the communication 
protocol:

msbuild Test.proj /t:RunTestsWithTestToolsTask

In both cases the MSTest actual command line looks like this:

"c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" 
/nologo /usestderr 
/searchpathroot:"C:\Users\lukaszw\Desktop\SeleniumTests\TestProject1\bin\Debug" 
/resultsfileroot:"C:\dev\dannarel\TR" 
/testcontainer:"C:\Users\lukaszw\Desktop\SeleniumTests\TestProject1\bin\Debug\Te
stProject1.dll"

From SysInternals Process Explorer:

Lots of zombie chromedriver/Chrome processes left. The tests timeout on the 
default timeout for MSTest tests which is 30sec.

Killing all the Chrome child processes leaves the parent chromedriver processes 
hanging, confirming that the communication channel is dead.

Here’s the console output of a hanging chomedriver:

Lukasz Wyrwinski
Software Developer
lukasz.wyrwinski@confirmit.com | Phone +47 2150 2582 | Mobile +47 92444651

Confirmit® [everywhere]

Software for Customer Feedback, Employee Feedback, and Market Research

Confirmit AS, Karenslyst allé 56, 0277 Oslo, Norway 
www.confirmit.com | Main +47 2150 2500 | Fax +47 2150 2501

The information contained in this email message may be privileged, confidential 
or exempt from disclosure under applicable law. If you are not the intended 
recipient, you are hereby notified that any use, dissemination, distribution or 
copying of this transmission is strictly prohibited. If you have received this 
communication in error, or if any problems occur with transmission, please 
notify the sender immediately.

Original comment by kjell.sa...@gmail.com on 8 Mar 2012 at 1:56

Attachments:

GoogleCodeExporter commented 9 years ago
Unfortunately I couldn't get my hands on visual studio tfs, so I couldn't 
reproduce your issue. Here's just a few ideas:

I notice the tabs are crashed in both screenshots. Does this happen immediately 
when chromedriver starts chrome? Can you manually open a new tab and navigate 
to a page, or do all pages crash? Can you try just starting Chrome from your 
test and see if you have the same behavior?

Can you attach the chromedriver.log file both from the case where it times out 
and where it works (using mstest directly)?

Original comment by kkania@chromium.org on 9 Mar 2012 at 6:54

GoogleCodeExporter commented 9 years ago
Yes, tab crashes immediately when driver start chrome. Manually opening new tab 
results in page crash, it is not possible to open any page.
I also tried starting chrome without navigating to any page and it also ends in 
page crash.
Chromedriver.log is empty when running RunTestsWithMSTestDirectly target.
RunTestsWithTestToolsTask results in just one line 
[0312/153813:ERROR:automation_proxy.cc(389)] Channel error in AutomationProxy.

Original comment by kjell.sa...@gmail.com on 12 Mar 2012 at 3:08

GoogleCodeExporter commented 9 years ago
What version of ChromeDriver are you using? If the latest, I'm surprised the 
log file is empty. If not, get the newest version and look at the log again.

Did you try starting Chrome directly from your test and seeing if that exhibits 
the tab crashing?

Original comment by kkania@chromium.org on 12 Mar 2012 at 4:11

GoogleCodeExporter commented 9 years ago
I updated to the latest version 18.0.1022.0.
Here is the log when using RunTestsWithMSTestDirectly target 
(direct_chromedriver.log)

Running RunTestsWithTestToolsTask (testtool_chromedriver.log)

Starting chrome using driver.Navigate() and running RunTestsWithTestToolsTask 
target also triggers tab crash (chromedriver.log)

Original comment by kjell.sa...@gmail.com on 14 Mar 2012 at 1:46

Attachments:

GoogleCodeExporter commented 9 years ago
Now I'm a bit confused. The testtool_chromedriver.log shows that the page 
navigated successfully, but for some reason it hangs while getting the current 
url. The chromedriver.log shows that ChromeDriver never saw a navigate command. 
What are you doing differently between the two exactly?

Also, if I understand you correctly, you are still using WebDriver to start 
Chrome directly. Can you try to start Chrome from your test without using 
WebDriver? Just launch the chrome.exe process (I suppose using some C# .NET 
API) and see if the tab crashing behavior is still there.

Original comment by kkania@chromium.org on 15 Mar 2012 at 5:41

GoogleCodeExporter commented 9 years ago
ChromeDriver.log was genereated when using Navigte() command without specifying 
a url. It didn't make any difference and chrome tab crashed when running 
TestToolsTask target.
driver.Navigate().GoToUrl(http://cnet.com); - File: direct_chromedriver.log and 
TestTool_chromedriver.log
driver.Navigate() - chromedriver.log

Launching chrome.exe process directly with the code listed below also results 
in tab crash when running RunTestsWithTestToolsTask target.
string userProfilePath = 
Environment.ExpandEnvironmentVariables("%userprofile%");
Process.Start(Path.Combine(userProfilePath, 
@"AppData\Local\Google\Chrome\Application\chrome.exe"));
Thread.Sleep(5000);

Original comment by kjell.sa...@gmail.com on 19 Mar 2012 at 7:05

GoogleCodeExporter commented 9 years ago
Thanks for the investigation and explanation. ChromeDriver is failing to 
connect because Chrome isn't sending the initial load message, which is 
probably not happening because the first tab crashes.

Even if we could get Chrome to send the initial tab load message and 
ChromeDriver was able to successfully connect, we'd still have to deal with the 
problem that Chrome's renderers crash when launched by TestToolsTask.

I'm not sure what could be going on, but here's a few things you could try:
1) Try adding --single-process when you run Chrome.exe from Process.Start
2) Try adding --no-sandbox when you run Chrome.exe from Process.Start
3) Check Chrome's log file and post its contents here. To get the log file, you 
need to run chrome with --enable-logging and --v=1 switches. This should result 
in a chrome_debug.log file being created in your user data directory (e.g., 
mine is 
C:\Users\kkania\AppData\Local\Google\Chrome\Application\17.0.963.79\chrome_debug
.log).  You can also specify the CHROME_LOG_FILE environment variable, which 
should override this location. See more details here: 
http://www.chromium.org/for-testers/enable-logging

Let me know the results of these 3 approaches.

Original comment by kkania@chromium.org on 19 Mar 2012 at 5:01

GoogleCodeExporter commented 9 years ago
1)  --single-process when you run Chrome.exe from Process.Start – “direct” 
target works,  tab still crashes when running with “tool” target
2)  --no-sandbox when you run Chrome.exe from Process.Start – no tab crash, 
both target starts chrome properly; the difference I noticed when running 
“tool” target is that when the test finishes browser window remains open 
(it is closed at the end when running “direct” target”)
3)  --enable-logging --v=1 arguments
RunTestsWithMSTestDirectly - chrome_debug_DIRECT.log
RunTestsWithTestToolsTask - chrome_debug_TOOL.log ; I had to manually close 
crashed tab since it remains open after test finishes and 
chrome_shutdown_ms.txt was generated in addition with numer 76 and second time 
84, third time 70…

Original comment by kjell.sa...@gmail.com on 28 Mar 2012 at 8:32

Attachments:

GoogleCodeExporter commented 9 years ago
For some reason Chrome is unable to correctly start the sandboxed renderer 
process when running in the tool mode.

So the test works now if you use --no-sandbox, but doesn't close properly when 
running with the TestToolsTask, is that correct? This is progress from before, 
right? Can you upload the chromedriver.log for running the test with 
TestToolsTask with --no-sandbox passed to ChromeDriver? I just want to make 
sure it is receiving the quit message, and see if it has any helpful info about 
why it is not quitting.

Original comment by kkania@chromium.org on 28 Mar 2012 at 4:49

GoogleCodeExporter commented 9 years ago
Yes, tab doesn't crash when --no-sandbox argument is specified and it doesn't 
close properly at the end (only when running TestToolsTask).
I'm attaching Chrome Debug Log when --no-sandbox is used (not ChromeDrive log 
since Chrome.exe is invoked by Process class directly).

Original comment by kjell.sa...@gmail.com on 29 Mar 2012 at 7:57

Attachments:

GoogleCodeExporter commented 9 years ago
Does the test work with ChromeDriver when you use --no-sandbox and the 
TestToolsTask? If not, can you get me the chromedriver log.

If you didn't know already, you can use 
(http://code.google.com/p/selenium/source/browse/trunk/dotnet/src/WebDriver/Chro
me/ChromeOptions.cs) to pass the --no-sandbox switch to chrome via chromedriver.

Original comment by kkania@chromium.org on 29 Mar 2012 at 4:48

GoogleCodeExporter commented 9 years ago
The test works with ChromeDriver in --no-sandbox mode when it is run by 
TestToolTask. I'm attaching driver log.

Original comment by kjell.sa...@gmail.com on 10 Apr 2012 at 8:57

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for all the feedback.  I am going to close this issue, since you have a 
workaround by passing --no-sandbox to chrome via chrome.switches.  If for some 
reason this isn't sufficient, feel free to comment on this bug or open a new 
bug.  I'd like to dig deeper and find out why the renderer crashes when the 
sandbox is enabled with the TestToolsTask, but I do not see this happening 
anytime soon.

For future reference, here's our findings:
With the TestToolsTask test runner in visual studio tfs, ChromeDriver fails to 
connect to Chrome.  This is most likely because Chrome is not reporting that 
the first tab has loaded, because the tab crashes.  The renderer also crashes 
when just running Chrome directly without ChromeDriver.  The crash does not 
occur when the sandbox is disabled.  From the logs in comment #12, the child 
process launcher is reporting a failure.

Original comment by kka...@google.com on 12 Apr 2012 at 11:40

GoogleCodeExporter commented 9 years ago
We are now using chromedriver.exe 23.0.1240.0 and we still experience that the 
browser is opened in multiple processes and the browser windows themselves 
seems to be just blank. 

Original comment by kjell.sa...@gmail.com on 9 Jan 2013 at 12:23

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by kkania@chromium.org on 13 Mar 2013 at 11:45

GoogleCodeExporter commented 9 years ago
Hi,

We are still struggling with not being able to run tests with Chrome from 
MSBuild. Passing the --no-sandbox is not something we want to do, I'm afraid. 
Running tests in Chrome with MSBuild works perfectly locally, but not on our 
build machine. Maybe the machine has to be set up in a certain way? At the 
moment it is set up the same way as our machine running Firefox tests, which 
works fine. 

Any help would be appreciated. 

Original comment by kjell.sa...@gmail.com on 4 Jun 2013 at 6:15

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:27