You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to start new projects and I got an exception when I try to use SelenoHost.Run , the problem seems to be with the structure of my testing class, I mean, the error is that I can't use a static method like SelenoHost.Run.
Update: At last I got a partial solution, if I declare an instance of SelenoHost and change some methods it works, maybe there has been a change in the source code?
Now I have problems with Navigate() and Find Methods.
I put below the exception:
Error 1 An object reference is required for non-static field, method, or property
Se requiere una referencia de objeto para el campo, método o propiedad no estáticos
The workaround is to add a class similar to this (as per the project readme):
publicstaticclassHost{publicstaticreadonlySelenoHostInstance=newSelenoHost();staticHost(){Instance.Run("Name.Of.Your.Web.Project",12346, c =>c.UsingLoggerFactory(newConsoleFactory())// If you are using MVC then do this where RouteConfig is the class that registers your routes in the "Name.Of.Your.Web.Project" project// If you aren't using MVC then don't include this line.WithRouteConfig(RouteConfig.RegisterRoutes));}}
Let us know how you get on?
Also, out of curiosity; we did change the package so when you install it you are now prompted with a readme that mentions the breaking changes file - did you see that?
p.s. We do try and minimise the number of breaking changes we make, but in our quest to get to 1.0 with a product that is great there are a few we need to make here and there.
Hi Rob, I didn't see the readme when installing the new version. In addition I needed some imports to create the class you mentioned. Wouldn't be interesting to create this class via nuget ?
I'm using this:
using Castle.Core.Logging;
using TestStack.Seleno.Configuration;
but still I got an error in RouteConfig.RegisterRoutes that is not recognized.
RouteConfig.RegisterRoutes will only be there if you are using MVC (and in fact you might call it a different name anyway). You only need that if navigating via MVC controller action lambda expressions - if not leave it out :)
The problem with creating that class using NuGet is that people might want to change it.
It's a good bit of feedback for us though as we may still decide to create a file that that class by default cc @MehdiK@mwhelan
The bit of code @robdmoore copied there is one of the ways you can instantiate SelenoHost and perhaps the most common one. SelenoHost is a disposable instance class and some devs might want to take control over its creation and disposal and this sample will be useless to them. One real example of when this snippet is not going to be useful and in fact might be confusing is when you want to run your tests on multiple browsers. In this case you will need an instance of SelenoHost per browser and the static class above won't cut it.
I personally think instantiating SelenoHost to be able to talk to Seleno is part of learning the API. We appreciate your confusion because you were using the old version with static host and there has been some breaking changes since; but as @robdmoore mentioned some breaking changes are inevitable before V1. The new users go through the documentation which is updated to reflect the new API and hopefully there won't be a confusion.
Activity
robdmoore commentedon Sep 26, 2013
Hi @micuentadecasa.
This is a known breaking change in version 0.5 that was documented here: https://github.com/TestStack/TestStack.Seleno/blob/master/BREAKING_CHANGES.md#selenohost-is-no-longer-static
The workaround is to add a class similar to this (as per the project readme):
Let us know how you get on?
Also, out of curiosity; we did change the package so when you install it you are now prompted with a readme that mentions the breaking changes file - did you see that?
p.s. We do try and minimise the number of breaking changes we make, but in our quest to get to 1.0 with a product that is great there are a few we need to make here and there.
Thanks!
micuentadecasa commentedon Sep 26, 2013
Hi Rob, I didn't see the readme when installing the new version. In addition I needed some imports to create the class you mentioned. Wouldn't be interesting to create this class via nuget ?
I'm using this:
using Castle.Core.Logging;
using TestStack.Seleno.Configuration;
but still I got an error in RouteConfig.RegisterRoutes that is not recognized.
robdmoore commentedon Sep 26, 2013
RouteConfig.RegisterRouteswill only be there if you are using MVC (and in fact you might call it a different name anyway). You only need that if navigating via MVC controller action lambda expressions - if not leave it out :)The problem with creating that class using NuGet is that people might want to change it.
It's a good bit of feedback for us though as we may still decide to create a file that that class by default cc @MehdiK @mwhelan
MehdiK commentedon Sep 26, 2013
Thanks for the feedback @micuentadecasa.
The bit of code @robdmoore copied there is one of the ways you can instantiate
SelenoHostand perhaps the most common one.SelenoHostis a disposable instance class and some devs might want to take control over its creation and disposal and this sample will be useless to them. One real example of when this snippet is not going to be useful and in fact might be confusing is when you want to run your tests on multiple browsers. In this case you will need an instance ofSelenoHostper browser and the static class above won't cut it.I personally think instantiating SelenoHost to be able to talk to Seleno is part of learning the API. We appreciate your confusion because you were using the old version with static host and there has been some breaking changes since; but as @robdmoore mentioned some breaking changes are inevitable before V1. The new users go through the documentation which is updated to reflect the new API and hopefully there won't be a confusion.
Hope this makes sense.
micuentadecasa commentedon Sep 26, 2013
I understand, thanks.
MehdiK commentedon Sep 26, 2013
I just added #106 to make sure breaking changes are shown on package update to avoid confusion in the future