Selenium ChromeDriver (C#) 仅在 Visual Studio 调试模式下崩溃 [英] Selenium ChromeDriver (C#) Crashes Only in Visual Studio Debug Mode

查看:73
本文介绍了Selenium ChromeDriver (C#) 仅在 Visual Studio 调试模式下崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 中运行用 C# 编写的 Selenium 测试时遇到问题.

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

我遇到的问题是,当我在调试模式下从工作室在 ChromeDriver 上运行测试时,chrome 窗口总是崩溃并皱眉.

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.

chromedriver 命令窗口循环显示以下错误(约 20 次).

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

这是我得到的痕迹:

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 更新 3

IDE: Visual Studio Enterprise 2015 Update 3

Chrome 驱动程序版本: 2.24.417431

Chrome Driver Version: 2.24.417431

底线:我希望能够从 Studio(在调试模式下)本身运行我的 Selenium 测试.有人可以帮我吗?

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?

推荐答案

我观察到如果 chrome 驱动程序版本与 chrome 浏览器版本不兼容,chrome 驱动程序(V2.28 之前)在操作浏览器时抛出错误(即最大化、调整大小等)

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.)

方案一:
使用 2.28 版,因为它修复了阻止 ChromeDriver 自动化扩展的错误从加载,从而导致窗口调整大小/定位 &截图功能打破.(注意 ChromeDriver 2.28 支持 Chrome v55-57)

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)

解决方案2:
如果您的 chrome 驱动程序未更新到 V2.28:使用适当的 Chromium 命令行开关(例如 chromeOptions.AddArguments(--start-maximized");) 操作浏览器并删除 driver.manage().window().maximize(); 如果有的话.

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.

如果此答案对您有用,请标记 +1.

Mark +1 if this answer is useful to you.

这篇关于Selenium ChromeDriver (C#) 仅在 Visual Studio 调试模式下崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆