-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not initialize Seleno - System.TypeInitializationException #231
Comments
After downloading the master source and playing with it I might have found the culprit. When I test with a |
Hi @oesolberg The problem is that you haven't upgraded the Selenium.Support package to 2.49. It's important that both the Selenium packages - WebDriver and Support - are the same version. |
Thanks for the tip, but it did not pan out. I am almost 100% sure it is Resharper test runner that has every test running in its environment. And that is not the test-directory. I ended up making my own hardcoded path to the websolution. Later I will make it a bit more dynamic.
|
I created a new class library, installed Seleno and ASP.Net MVC from NuGet, and encountered the same issue you had with System.TypeInitializationException. I upgraded Selenium WebDriver and Support to the latest versions and it fixed the problem. I am using the ReSharper runner as well. This issue looks a lot like issue #218 . Do you want to have a look at your solution folder structure and see if it is causing the same problem that was there? |
I am running the almost latest version of Resharper Ultimate (10.0.1) with VS2015 update 1. Just to confirm I created a new solution with a webapplication(MVC) and a testproject. Both located default. But after doing update of both Webdriver and Support I still get the same error. Packages.config after updates
No problem. It works as long as I insert the correct directory as shown in my previous post. |
Hi @oesolberg . I'm glad you got it working. Specifying the location of the project is a good solution, which is catered for by the overload you have used. There is work we can do to improve the smarts of how Seleno searches for the project directory and also to throw a more meaningful exception when things don't work out so it is clear to the user what happened during the project search. |
Hi @oesolberg . I have looked at this more closely and it seems that the issue is with changes NUnit has made and the impact it has on Environment.CurrentDirectory. (My repro of your issue used NUnit 2.64, which is why I could not replicate the issue). As I expect a lot of people to move to be using NUnit 3 I think this is an issue we will have to address in Seleno. You can read more about the NUnit 3 changes here (and the issues it has created for people relying on the old NUnit 2 behaviour). |
Thanks. Good to see that it is not just me (even though it is sad that this will affect everyone going over to nUnit 3). |
Hi @oesolberg . This fix has been released to NuGet as version 0.9.56. |
Thanks for all the support and quick update of the NuGet package! |
I am getting this same error now, since i was following the tutorial. I am using Microsoft test. |
I am new to Seleno so I might have misunderstood something,
I am trying to get Seleno to work. Following the course Automated ASP.NET MVC Testing: End to End on Pluralsight by Jason Roberts.
But for some reason I cant get Seleno to work.
I create a solution with the ASP.Net MVC (.net 4.6). Works like it should.
WebApplication (solution)
\WebApplication
\Tests
After doing the Install-packages I have the following packages-config
I add a test project with the following packages:
package id="Castle.Core" version="3.3.3" targetFramework="net46"
package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net46"
package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net46"
package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net46"
package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46"
package id="NUnit" version="3.0.1" targetFramework="net46"
package id="Selenium.Support" version="2.45.0" targetFramework="net46"
package id="Selenium.WebDriver" version="2.49.0" targetFramework="net46"
package id="TestStack.Seleno" version="0.9.11" targetFramework="net46"
I tried to make a little test but I always get the following error on initialising the BrowserHost.
System.TypeInitializationException : The type initializer for 'Tests.BrowserHost' threw an exception.
----> System.NullReferenceException : Object reference not set to an instance of an object.
at Tests.DudeTest.Something() in c:\dev\WebApplication\Tests\DudeTest.cs:line 12
--NullReferenceException
at TestStack.Seleno.Configuration.WebServers.ProjectLocation.GetSolutionFolderPath() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\WebServers\ProjectLocation.cs:line 42
at TestStack.Seleno.Configuration.WebServers.ProjectLocation.FromFolder(String webProjectFolderName) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\WebServers\ProjectLocation.cs:line 33
at TestStack.Seleno.Configuration.SelenoHost.Run(String webProjectFolder, Int32 portNumber, Action`1 configure) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\SelenoHost.cs:line 51
at Tests.BrowserHost..cctor() in c:\dev\WebApplication\Tests\BrowserHost.cs:line 17
I found that this has been a problem before, but then the solution was to have the .sln file correctly located. As it is now I think I have It right.
Is there anything I am missing or am I using the wrong .Net version?
BrowserHost.cs
using TestStack.Seleno.Configuration;
namespace Tests
{
public static class BrowserHost
{
public static readonly SelenoHost Instance=new SelenoHost();
public static readonly string RootUrl;
static BrowserHost()
{
Instance.Run("WebApplication", 12345);
RootUrl = Instance.Application.Browser.Url;
}
}
}
TestClass.cs
using NUnit.Framework;
using OpenQA.Selenium;
namespace Tests
{
[TestFixture]
public class DudeTest
{
[Test]
public void Something()
{
BrowserHost.Instance.Application.Browser.Navigate().GoToUrl(BrowserHost.RootUrl+@"Lub");
The text was updated successfully, but these errors were encountered: