angularjs – 无法使用phantomjs进行量角器测试
发布时间:2020-12-17 18:09:31 所属栏目:安全 来源:网络整理
导读:我正在使用量角器来测试Angular代码.当我通过chromedriver驱动程序运行它时,测试运行正常,默认情况下使用webdriver-manager.现在我想用phantomjs(无头浏览器)运行相同的测试,因为我需要通过服务器运行此测试.但是当通过phantomjs运行测试时,我收到错误: Fai
我正在使用量角器来测试Angular代码.当我通过chromedriver驱动程序运行它时,测试运行正常,默认情况下使用webdriver-manager.现在我想用phantomjs(无头浏览器)运行相同的测试,因为我需要通过服务器运行此测试.但是当通过phantomjs运行测试时,我收到错误:
Conf文件是: 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的说明安装了量角器并通过安装了phantomjs sudo apt-get install phantomjs 解决方法
你增加错误的超时:
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000000; 这个超时是茉莉花测试不能运行太久.如果你想等待页面上的页面加载和角度更长 – 将其添加到量角器配置文件: getPageTimeout: timeout_in_millis //default 10 sec allScriptsTimeout: timeout_in_millis //default 11 sec 更多关于超时的信息 – http://www.protractortest.org/#/timeouts 还要检查是否指向正确的根元素: // CSS Selector for the element housing the angular app - this defaults to // body,but is necessary if ng-app is on a descendant of <body>. rootElement: 'body', 我不打算在phantomJS上推荐runnning protractor测试,它与真正的浏览器有很大的不同,有时候你可能会跳过真正的bug,或者找到特定于phantomJS的东西. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |