Selenium: WebDriver - System.TypeLoadException unhandled every time I run the most basic project

拥有回忆 提交于 2019-12-25 11:54:52

问题


Error details:

System.TypeLoadException was unhandled
HResult=-2146233054
Message=Could not load type 'OpenQA.Selenium.Firefox.FirefoxDriver' from assembly
>'WebDriver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source=WebDriver
TypeName=OpenQA.Selenium.Firefox.FirefoxDriver
StackTrace:
at Driver.Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
>executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
>ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
>ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
InnerException:

I am running Visual C# 2010 on Windows 8. I changed the target framework to .Net framework 4 (from .Net framework 4 Client Profile). I tried the big three browsers:

    //IWebDriver driver = new FirefoxDriver();
    //IWebDriver driver = new ChromeDriver();
    IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver();

Same error every time (basically, anyway). The code comes straight out of their docs: http://docs.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example

Any help would be greatly appreciated. Just starting out with Selenium, hoping to automate a few simple tasks to start out. If I figure it out before I get an answer, I'll post it as an update.

Edit: tried to clean up formatting a bit.


回答1:


This error occurred because I tried to compile a new Selenium based project before I added the references. After I realized the mistake I added references to all the assemblies, and still got the error. Turns out Visual Studio was "stuck" as I am now aware is not uncommon. A quick restart of the IDE was all that was necessary.



来源:https://stackoverflow.com/questions/17224060/selenium-webdriver-system-typeloadexception-unhandled-every-time-i-run-the-mo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!