問題描述
我有一個在 http://localhost:6543
上運行的應用程序 - 這是一個 Pyramid 應用程序.
I have an app running on http://localhost:6543
- it's a Pyramid app.
- 此應用在/處為 AngularJS 應用提供服務
- 此應用使用 socket.io 本身
問題是:是否可以使用這些工具測試該應用程序?
我的 scenario.js
文件中有這個:
I have this in my scenario.js
file:
beforeEach(function() {
browser().navigateTo('http://localhost:6543/');
});
但當我啟動 testacular(使用 run
或 start
)時,我收到以下錯誤消息:
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.
所以我知道瀏覽器不允許訪問 iframe
的文檔,因為這會違反跨域.
so I understand the browser doesn't give access to the iframe
's document, because it'd be some Cross-Origin violation.
我嘗試了什么:
- 使用 Testacular 網絡服務器(使用
proxies
選項)代理到我的應用程序,但/
會與 Testacular 自己的框架服務沖突.此外,這兩個應用程序最終都會嘗試使用/socket.io
,這也會發生沖突. - 做相反的事情(調整我的應用程序以代理到 Testacular 的服務器),但是,我們會遇到與
/socket.io
相同的問題.
- 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!
推薦答案
而不是有
beforeEach(function() {
browser().navigateTo('http://localhost:6543/');
});
把這個改成
beforeEach(function() {
browser().navigateTo('/');
});
然后在你的 testacular-e2e.conf.js 文件中添加:
and then in your testacular-e2e.conf.js file add:
proxies = {
'/': 'http://localhost:6543/'
};
您可能還有其他問題,但我可以重現沙盒錯誤:無法訪問應用程序文檔".僅包含 Pyramid Hello World App 和此配置問題的消息.
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.
這篇關于如何使用 Testacular + AngularJS 測試外部服務的應用程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!