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