zhenbzha zhenbzha - 1 year ago 140
AngularJS Question

Scenario test in AngularJS

I am using AngularJS for my web application. To do the e2e routing scenario testing, based on tutorial, I need to do something like browser().navigateTo('../../app/index.html'). However, I am using cshtml as my main view, which is blocked from direct server browsing. So I cannot do something like browser().navigateTo('../../app/index.cshtml').

I would like the browser to navigate to the application root instead of specific file. I do something like browser().navigateTo('../../'). However, I get following error "TypeError: Cannot call method '$browser' of undefined". I think that is due to "ng-app" in index.cshtml is not included. Is there some easy way to solve this?

Answer Source

You can navigateTo any url, but it has to be on the same domain, because of the same domain policy (scenario runner needs to access the app within the iframe).

This can be workarounded by a proxy. Or you might serve the scenario runner (runner.html) by your app server, that might be even easier solution.

You need ng-app, so that scenario runner can find the $injector, so even if you do manual bootstrap, put the ng-app attribute onto the root element of the app.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download