2

I am trying to build a selenium-silverlight UI test using selenium Nuint test framework. Here is my code

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

Project/Solution builds without any errors but when I debug/run the test case from test it fails with following error.

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()

I can't figure out why it is able to compile with Silvernium Assembly reference added but not able to load Silvernium assembly at run/debug time.

Code for 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);
        }
    }
}

And Error Log for 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()
Rahul Lodha
  • 3,601
  • 7
  • 25
  • 34
  • You should make sure that the references are there for both the production project and the test project. Also if you are running the test from a different client machine than the one building it, make sure Silverlight is installed on that machine. – Evan L Feb 03 '14 at 23:09
  • Can you try every answer in this thread http://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its-dependencies – PUG Feb 03 '14 at 23:09
  • @Evan L I am running test on my local only and I have silverlight installed. Also i have references added in test project otherwise build would fail. – Rahul Lodha Feb 03 '14 at 23:15
  • On the machine it fails on, does Silvernium's library exist in that folder? Is it in the GAC? – Arran Feb 04 '14 at 14:51
  • @Arran yes it does, else it would fail on compile/build. This is a run/debug time error. – Rahul Lodha Feb 04 '14 at 15:50
  • No one ran into this problem ever using silvernium? – Rahul Lodha Feb 04 '14 at 19:58
  • @Arran I tried same test case with MSTest. Updated code and Error log are posted above. – Rahul Lodha Feb 05 '14 at 20:33

2 Answers2

2

I just had the same error today. Try changing the name of your Silvernium dll from Silvernium-version.number.dll to Silvernium.dll.

For example, I changed mine from Silvernium-1.1.dll to Silvernium.dll and it worked.

0

Reinstall of selenium nuget package will fix the problem.

Had fixed few mins ago the same problem.

Andrew_STOP_RU_WAR_IN_UA
  • 9,318
  • 5
  • 65
  • 101