Selenium ChromeDriver (C#) Crashes Only in Visual Studio Debug Mode

半城伤御伤魂 提交于 2019-12-12 17:04:47

问题


I am facing an issue running my Selenium tests written in C# in Visual Studio.

The issue I have is when I run the tests on ChromeDriver from the studio in debug mode, the chrome window always crashes with a frowny face.

The chromedriver command window shows the following error in a loop (~20 times).

Starting ChromeDriver 2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf) on port 52376
Only local connections are allowed.
[28356:19528:0922/134628:ERROR:child_process_launcher.cc(528)] Failed to launch child process

This is the trace I get:

at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)

at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)

at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)

at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)

at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)

at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)

at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options)

The best part is that when I run the test directly from the explorer (outside the studio), it works just fine.

I use a test runner built by someone else. I am not sure what the runner is using.

IDE: Visual Studio Enterprise 2015 Update 3

Chrome Driver Version: 2.24.417431

Bottomline: I want to be able to run my Selenium tests from the Studio (in debug mode) itself. Can anyone please help me out here?


回答1:


I have observed that if chrome driver version is not compatible with chrome browser version, chrome driver (before V2.28) is throwing errors while manipulating the browser (i.e. Maximize, resize etc.)

Solution 1:
Use Version 2.28 as it has fixed a bug which blocked ChromeDriver automation extension from loading and thereby causing window resizing/positioning & screenshot functionalities to break. (Note that ChromeDriver 2.28 supports Chrome v55-57)

Solution 2:
If your chrome driver is not updated to V2.28: Use appropriate Chromium Command Line Switch (ex. chromeOptions.AddArguments("--start-maximized");) to manipulate the browser and remove the line driver.manage().window().maximize(); if any.

Mark +1 if this answer is useful to you.



来源:https://stackoverflow.com/questions/39645918/selenium-chromedriver-c-crashes-only-in-visual-studio-debug-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!