Skip to content
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

Access MVC Areas in Seleno UI Testing #257

Open
Kalyan-Basa opened this issue Mar 23, 2017 · 6 comments
Open

Access MVC Areas in Seleno UI Testing #257

Kalyan-Basa opened this issue Mar 23, 2017 · 6 comments

Comments

@Kalyan-Basa
Copy link

I have two modules in our Application and we have setup two areas for each of the module.

Ex:
Area1

  • Apply
  • Accepted
  • Rejected

Similarly for Area2

  • Apply
  • Accepted
  • Rejected

The following are the routes

  • Area1/Apply/ActionMethod
  • Area2/Accepted/ActionMethod

Using Seleno, I'm able to access routes without the Areas.
i.e., /Apply/ActionMethod

But I want to integrate Areas as well in the Seleno UI Functional testing project.

While initiating SelenoHost, I have configured routes as below

Instance.Run("ProjectName", portNumber,
                config => config.WithRouteConfig(RouteConfig.RegisterRoutes)
                );

Thanks in Advance.

@mwhelan
Copy link
Member

mwhelan commented Mar 23, 2017

Hi @Kalyan-Basa . Assuming your areas are registered in the RegisterRoutes method, there is an overload of NavigateToInitialPage that takes a dictionary of route values. This can be used to populate the area value.

var routeValues = new Dictionary<string, object> { { "area", "Area1" } };
SUT.NavigateToInitialPage<TestController, TestPage>(c => c.Details(23), routeValues);

Thanks

@Kalyan-Basa
Copy link
Author

Hi @mwhelan , I have tried the above approach but this how my URL is getting formed (Got this from browser Developer Tools.)

http://localhost:519/Test/Details?area=Area1

whereas, I wanted it to be

http://localhost:519/Area1/Test/Details

Thanks

@mwhelan
Copy link
Member

mwhelan commented Mar 23, 2017

Not sure if 'area' should be case sensitive? Try

var routeValues = new Dictionary<string, object> { { "Area", "Area1" } };
SUT.NavigateToInitialPage<TestController, TestPage>(c => c.Details(23), routeValues);

@Kalyan-Basa
Copy link
Author

No, it doesn't help.

@mwhelan
Copy link
Member

mwhelan commented Mar 23, 2017

Do you have the areas registered in RegisterRoutes method?

@Kalyan-Basa
Copy link
Author

Yes, I've my areas registered in MVC application like the below.

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "Area1",
                url: "Area1/{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "Area2",
                url: "Area2/{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants