Selenium ChromeDriver (C#) Crashes Only in Visual

2019-07-09 03:34发布

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.

enter image description here

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条回答
Evening l夕情丶
2楼-- · 2019-07-09 04:04

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.

查看更多
登录 后发表回答