c# - System.IO.FileNotFoundException : Could not load file or assembly 'Silvernium, 版本=1.0.4254.29979

标签 c# silverlight nunit selenium-rc ui-automation

我正在尝试使用 selenium Nuint 测试框架构建 selenium-silverlight UI 测试。 这是我的代码

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using System.Text;
using OpenQA.Selenium.Interactions;
using System.Configuration;
using System.Threading;
using Selenium;
using ThoughtWorks.Selenium.Silvernium;
using DBServer.Selenium.Silvernium.Fixtures;
using NUnit.Framework;

namespace Rahul_Test
{
[TestFixture]
public class UnitTest1
{
    protected static IWebDriver driver;
    protected WebDriverWait wait;
    protected StringBuilder verificationErrors;
    private string baseURL;
    protected static Actions builder;
    protected Silvernium silvernium;
    protected ISelenium selenium;
    protected ICommandProcessor processor;

    //initial setup
    [SetUp]
    public void SetupTest()
    {
        selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com");
        selenium.Start();
        selenium.Open("http://atlas/Dev/Axioma/");
        silvernium = new Silvernium(selenium, "InteractiveElement");  //this line throws error at runtime/while running tests in debug mode...
        //Note: Build does not throw any errors on compilation
    }

    //open browser test case
    [Test]
    public void Login()
    {
        NUnit.Framework.Assert.IsFalse(false);
    }
}

项目/解决方案构建时没有任何错误,但是当我从测试中调试/运行测试用例时,它失败并出现以下错误。

Test Name: Login

Test FullName: Rahul_Test.UnitTest1.Login

Test Source: c:\Users\rlodha\Documents\Visual Studio 2012\Projects\SampleUITest\SampleUITest\UnitTest1.cs : line 58

Test Outcome: Failed

Test Duration: 0:00:00.205

Result Message: SetUp : System.IO.FileNotFoundException : Could not load file or assembly 'Silvernium, Version=1.0.4254.29979, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

The system cannot find the file specified. Result StackTrace: at Rahul_Test.UnitTest1.SetupTest()

我不明白为什么它能够在添加了 Silvernium 程序集引用的情况下进行编译,但无法在运行/调试时加载 Silvernium 程序集。

MSTest 代码

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using System.Text;
using OpenQA.Selenium.Interactions;
using System.Configuration;
using System.Threading;
using Selenium;
using ThoughtWorks.Selenium.Silvernium;
//using NUnit.Framework;

namespace Rahul_Test
{
    [TestClass]
    public class UnitTest1
    {
        //copy this part for defining a class for IE and chrome
        protected static IWebDriver driver;
        protected WebDriverWait wait;
        protected StringBuilder verificationErrors;
        private string baseURL;
        protected static Actions builder;
        protected Silvernium silvernium;
        protected ISelenium selenium;
        //protected ICommandProcessor processor;
        //initial setup
        [TestInitialize]
        public void SetupTest()
        {
            if (driver == null)
            {
                driver = new FirefoxDriver();
                driver.Manage().Window.Maximize();
                baseURL = "";
                verificationErrors = new StringBuilder();
                driver.Navigate().GoToUrl("http://atlas/Dev/Axioma/");
                builder = new Actions(driver);
                //processor=new 
                selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com");
                //selenium.Start();
                //selenium.Open("http://atlas/Dev/Axioma/");
                silvernium = new Silvernium(selenium, "InteractiveElement");
                //var silverlightapp = new SilverlightApplicationFixture("localhost", 4444, "*firefox", "http://www.google.com");
                // }
                //wait = new WebDriverWait(driver, TimeSpan.FromSeconds(35));
                //wait = new WebDriverWait(driver, TimeSpan.FromSeconds(Convert.ToInt16(ConfigurationManager.AppSettings["TimeOut"])));
            }
        }

        //open browser test case
        [TestMethod]
        public void Login()
        {
            Assert.IsFalse(false);
        }
    }
}

MSTest 的错误日志

Test Name:Login
Test FullName:Rahul_Test.UnitTest1.Login
Test Source:c:\Users\rlodha\Documents\Visual Studio 2012\Projects\SampleUITest\SampleUITest\UnitTest1.cs : line 57
Test Outcome:Failed
Test Duration:3.36805555555556E-06

Result Message:
Initialization method Rahul_Test.UnitTest1.SetupTest threw exception. System.IO.FileNotFoundException: System.IO.FileNotFoundException: Could not load file or assembly 
'Silvernium, Version=1.0.4254.29979, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
The system cannot find the file specified.Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.exe.config

=== Pre-bind state information ===
LOG: DisplayName = Silvernium, Version=1.0.4254.29979, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/rlodha/Documents/Visual Studio 2012/Projects/SampleUITest/SampleUITest/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : SampleUITest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
.
Result StackTrace:at Rahul_Test.UnitTest1.SetupTest()

最佳答案

我今天也遇到了同样的错误。尝试将 Silvernium dll 的名称从 Silvernium-version.number.dll 更改为 Silvernium.dll。

例如,我将我的从 Silvernium-1.1.dll 更改为 Silvernium.dll 并且它有效。

关于c# - System.IO.FileNotFoundException : Could not load file or assembly 'Silvernium, 版本=1.0.4254.29979,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21539668/

相关文章:

c# - 为什么 MessageBox 类在 C# 中没有默认构造函数?

c# - 如何选择 GridView 中某一特定列中的所有复选框?

silverlight - 是否可以在Silverlight 5中显示隔离存储路径

silverlight - Resharper 支持 Silverlight 单元测试应用程序

nunit - 使用 NANT 通过 NCover 运行 NUnit

c# - 验证cname记录

c# - 打开 rdlc 报告时在报告查看器中手动设置值

.net - 使用 Silverlight 的多个屏幕/监视器

testing - 如何在没有混合测试的情况下运行按同一命名空间中的类别排序的 nunit 测试?

c# - 如何使用列表和关系对象测试 fluent-NHibernate 的 PersistenceSpecification.VerifyTheMappings?