简体   繁体   English

Selenium ChromeDriver每次尝试运行时都会给我SerializationException

[英]Selenium ChromeDriver gives me SerializationException every time I try to run it

I have created NUnit suite that initialises Chrome Webdriver in Selenium. 我创建了NUnit套件,用于在Selenium中初始化Chrome Webdriver。 This works fine with InternetExplorer driver and Firefox driver however fails with SerializationException every time I try to run it with Chrome driver. 这适用于InternetExplorer驱动程序和Firefox驱动程序,但每次我尝试使用Chrome驱动程序运行时,都会因SerializationException而失败。

Anyone can point me in right direction? 任何人都可以指出我正确的方向?

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");
    }
  }
}

This is error I get: 这是我得到的错误:

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)

I am not into NUnit, but I believe that IWebDriver class is for Internet Explorer only - but that applies to Java 我不是NUnit,但我相信IWebDriver适用于Internet Explorer - 但这适用于Java

Do you have class WebDriver also? 你有WebDriver课程吗? If yes, try using it. 如果是,请尝试使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试使用 dockerfile 运行我的 Selenium 项目时,它告诉我找不到 chromedriver - When I try to run my Selenium project with a dockerfile it tells me that the chromedriver cannot be found 硒每次都找不到元素给我例外 - selenium not able to find Elements every time gives me exception chromedriver.exe在PATH中,但是硒给我一个错误 - chromedriver.exe is in PATH, but selenium gives me an error 当我尝试将Selenium与python结合使用以打开Chrome浏览器时,Windows给我一个FileNotFoundError:[WinError 2] - When I try to use Selenium with python to open a Chrome browser, windows gives me a FileNotFoundError: [WinError 2] ChromeDriver无法运行(Selenium Webdriver) - ChromeDriver Will not run (Selenium Webdriver) 在Jenkins中使用chromedriver运行Selenium - Run Selenium with chromedriver in Jenkins 我可以使用实际Chrome安装的Cookie运行Selenium ChromeDriver吗? - Can I run Selenium ChromeDriver with cookies from actual Chrome installation? Selenium ChromeDriver - 在后台运行但不是无头 - Selenium ChromeDriver - Run in background but not headless 尝试无头运行 selenium chromedriver? - Trying to run selenium chromedriver headless? 为什么每次尝试使用硒测试脚本登录Naukari.com时都会出现1001错误? - Why do I get 1001 error every time I try to login into Naukari.com using my selenium test script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM