運行我能想到的最基本的硒測試。硒鉻未能啓動
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Firefox;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
String path = @"D:\Selenium Webdrivers\ChromeDriver\";
IWebDriver driver;
driver = new ChromeDriver(path);
}
}
}
我使用,
- 的Chrome版本52.0.2743.82米
- ChromeDriver 2.22
- 硒的webdriver 2.53.1
- 硒的webdriver支持類2.53.1
- win10 (最近升級)
我已經嘗試卸載並重新安裝chrome並刪除用戶配置文件。
錯誤我得到的是,
Test Name: TestMethod1 Test FullName: UnitTestProject1.UnitTest1.TestMethod1 Test Source: c:\Users\user\Documents\Visual Studio 2013\Projects\UnitTestProject1\UnitTestProject1\UnitTest1.cs : line 13 Test Outcome: Failed Test Duration: 0:00:01.3305496
Result Message: Test method UnitTestProject1.UnitTest1.TestMethod1 threw exception: System.InvalidOperationException: unknown error: chrome failed to start (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 10.0.10586 x86_64) Result StackTrace: at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) 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(String chromeDriverDirectory, ChromeOptions options) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory) at UnitTestProject1.UnitTest1.TestMethod1() in c:\Users\user\Documents\Visual Studio 2013\Projects\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 15
'driver = new FirefoxDriver();'將正常工作。似乎只是鉻。 – user3881000
Chrome瀏覽器的舊版本是否在您正在測試的機器上的某個地方出現,並且正在嘗試使用該WebDriver? – Josh