【发布时间】:2016-06-24 12:18:10
【问题描述】:
我正在使用量角器来测试 Angular 代码。当我通过默认带有 webdriver-manager 的 chrome 驱动程序运行测试时,测试运行良好。现在我想用 phantomjs(无头浏览器)运行相同的测试,因为我需要通过服务器运行这个测试。但是在通过 phantomjs 运行测试时出现错误:
失败:在页面 URL 上找不到 Angular:重试查找 Angular 超出范围
配置文件是:
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['demo-test.js'],
capabilities: {
browserName: 'phantomjs',
version: '',
platform: 'ANY'
};
demo-test.js 文件看起来像:
// demo-test.js
describe('Protractor Demo App', function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000000;
beforeEach(function() {
browser.driver.manage().window().setSize(1280, 1024);
});
it('should have a title', function() {
browser.get('URL');
expect(browser.getTitle()).toEqual('Title');
});
请帮帮我。我已经按照官方site 的说明安装了量角器,并通过
安装了phantomjssudo apt-get install phantomjs
【问题讨论】:
-
我不推荐使用量角器的 phantomJS。而是尝试在您的服务器上使用带有 chrome 的 XVFB 来运行带有虚拟显示器的浏览器。
-
嘿@martin770 感谢您的建议,您能否提供任何文档链接,我可以在其中找到如何执行此操作?
标签: angularjs phantomjs protractor