我在Visual Studio中运行用C#编写的Selenium测试时遇到了问题。
我遇到的问题是,当我在调试模式下从工作室运行ChromeDriver上的测试时,Chrome窗口总是会因为皱眉脸而崩溃。
chromedriver命令窗口在循环中显示以下错误(~20次)。
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)
最好的部分是,当我直接从资源管理器(工作室外)运行测试时,它的工作正常。
我使用其他人构建的测试运行器。我不确定跑步者正在使用什么。
IDE: Visual Studio Enterprise 2015 Update 3
Chrome驱动程序版本: 2.24.417431
底线:我希望能够从Studio(在调试模式下)运行我的Selenium测试。有人可以帮帮我吗?
答案 0 :(得分:1)
我观察到如果Chrome驱动程序版本与chrome浏览器版本不兼容,则Chrome驱动程序(V2.28之前)在操作浏览器时会抛出错误(即最大化,调整大小等)
解决方案1:
使用Version 2.28,因为它修复了阻止ChromeDriver自动化扩展加载的错误,从而导致窗口调整大小/定位&截图功能打破。 (请注意,ChromeDriver 2.28支持Chrome v55-57)
解决方案2:
如果您的Chrome驱动程序未更新为V2.28:使用适当的Chromium Command Line Switch(例如chromeOptions.AddArguments("--start-maximized");
)操纵浏览器并删除行driver.manage().window().maximize();
(如果有)。
如果此答案对您有用,请标记+1。