2012-03-12 68 views
3

我已經創建了在Selenium中初始化Chrome Webdriver的NUnit套件。這適用於InternetExplorer驅動程序和Firefox驅動程序,但每次嘗試使用Chrome驅動程序運行時都會失敗並顯示SerializationException。Selenium ChromeDriver每次嘗試運行時都會給我SerializationException

任何人都可以指向正確的方向嗎?

namespace TestNamespace 
{ 
using System; 
using NUnit.Framework; 
using NUnit.Core; 
using SeleniumTests; 
using OpenQA.Selenium; 
using OpenQA.Selenium.IE; 
using OpenQA.Selenium.Firefox; 
using OpenQA.Selenium.Chrome; 
using OpenQA.Selenium.Support.UI; 

    class AllInOne 
    { 
    public static IWebDriver WebDriver { get; private set; } 

    [Suite] 
    public static TestSuite Suite 
    { 
     get 
     { 
      TestSuite suite = new TestSuite("All Tests"); 

      SetupChrome(); 

      suite.Add(new FlashLoadedTest { Driver = WebDriver }); 

      return suite; 
     } 
    } 


    private static void SetupChrome() 
    { 
     WebDriver = new ChromeDriver(@"C:\Users\<username>\AppData\Local\Google\Chrome\Application"); 
    } 
    } 
} 

這是錯誤,我得到:

Unhandled Exception: 
System.Runtime.Serialization.SerializationException: Unable to find assembly 'WebDriver, Version=2.15.0.0, Culture=neutral, PublicKeyToken=1c2bd1631853048f'. 

Server stack trace: 
    at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() 
    at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) 
    at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) 
    at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) 
    at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) 
    at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum) 
    at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() 
    at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) 
    at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) 
    at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm) 
    at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeMessageParts(MemoryStream stm) 
    at System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.FixupForNewAppDomain() 
    at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg) 

Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at NUnit.Core.TestRunner.Load(TestPackage package) 
    at NUnit.Util.TestDomain.Load(TestPackage package) 
    at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options) 
    at NUnit.ConsoleRunner.Runner.Main(String[] args) 

回答

0

我不是到NUnit的,但我相信IWebDriver類是Internet Explorer 只有 - 但適用於Java的

待辦事項你有課WebDriver也?如果是,請嘗試使用它。

相關問題