javascript - How do I test an externally served app using Testacular + AngularJS - Stack Overflow

admin2025-04-22  0

I have an app running on http://localhost:6543 - it's a Pyramid app.

  • This app serves the AngularJS app at /
  • This app uses socket.io itself

The question is: is it possible to test that application using those tools ?

I have this in my scenario.js file:

beforeEach(function() {
   browser().navigateTo('http://localhost:6543/');
});

but the moment I launch testacular (with run or start), I get this error message:

Chrome 23.0 registration: should delete all cookies when user clicks on "remove all" button FAILED
browser navigate to 'http://localhost:6543/'
/home/abourget/myapp/jstests/scenarios/registration_scenario.js:9:5: Sandbox Error: Application document not accessible.

so I understand the browser doesn't give access to the iframe's document, because it'd be some Cross-Origin violation.

What I tried:

  • Proxying to my app using the Testacular web server (with the proxies option), but / would conflict with Testacular's own serving of its framework. Also, both apps would eventually try to use /socket.io and that would conflict also.
  • Doing the reverse (tweaking my app to proxy to Testacular's server), but then, we'd get the same issues with /socket.io.

Thanks for these great tools, btw!

I have an app running on http://localhost:6543 - it's a Pyramid app.

  • This app serves the AngularJS app at /
  • This app uses socket.io itself

The question is: is it possible to test that application using those tools ?

I have this in my scenario.js file:

beforeEach(function() {
   browser().navigateTo('http://localhost:6543/');
});

but the moment I launch testacular (with run or start), I get this error message:

Chrome 23.0 registration: should delete all cookies when user clicks on "remove all" button FAILED
browser navigate to 'http://localhost:6543/'
/home/abourget/myapp/jstests/scenarios/registration_scenario.js:9:5: Sandbox Error: Application document not accessible.

so I understand the browser doesn't give access to the iframe's document, because it'd be some Cross-Origin violation.

What I tried:

  • Proxying to my app using the Testacular web server (with the proxies option), but / would conflict with Testacular's own serving of its framework. Also, both apps would eventually try to use /socket.io and that would conflict also.
  • Doing the reverse (tweaking my app to proxy to Testacular's server), but then, we'd get the same issues with /socket.io.

Thanks for these great tools, btw!

Share Improve this question edited Apr 6, 2013 at 13:45 dantheta 1,1072 gold badges13 silver badges29 bronze badges asked Nov 29, 2012 at 17:28 abourgetabourget 2,41921 silver badges17 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5

Instead of having

beforeEach(function() {
    browser().navigateTo('http://localhost:6543/');
});

change this to

beforeEach(function() {
    browser().navigateTo('/');
});

and then in your testacular-e2e.conf.js file add:

proxies = {
    '/': 'http://localhost:6543/'
};

You might still have other issues, but I can reproduce the "Sandbox Error: Application document not accessible." message with just the Pyramid Hello World App and this configuration problem.

We had a similar problem, and had already proxies and navigateTo('/'). We needed to add some urlRoot to avoid conflicts when loading socket.io. We simply added '/e2e' and that was enough to solve the conflict. Actually, there was a warning message when running testacular for this issue.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745275805a293861.html

最新回复(0)