I am using protractor to test Angular code. The test is running fine when i am running it via chrome driver that comes by default with webdriver-manager. Now I want to run same test with phantomjs (headless browser) as i need to run this test via server. But while running test via phantomjs I am getting error:
我正在使用量角器来测试Angular代码。当我通过chromedriver驱动程序运行它时,测试运行正常,默认情况下使用webdriver-manager。现在我想用phantomjs(无头浏览器)运行相同的测试,因为我需要通过服务器运行此测试。但是当通过phantomjs运行测试时,我收到错误:
Failed: Angular could not be found on the page URL : retries looking for angular exceeded
失败:在页面URL上找不到Angular:重试超出角度的重试次数
Conf file is:
配置文件是:
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['demo-test.js'],
capabilities: {
browserName: 'phantomjs',
version: '',
platform: 'ANY'
};
demo-test.js file looks like:
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');
});
Please help me out. I have installed protractor by using instructions from official site and installed phantomjs via
请帮帮我。我已经使用官方网站的说明安装了量角器,并通过安装了phantomjs
sudo apt-get install phantomjs
sudo apt-get install phantomjs
1 个解决方案
#1
1
You increasing wrong timeout:
你增加错误的超时:
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000000;
This timeout is for jasmine test not to run for too long. If you want to wait for page load and angular on the page longer - add this to protractor config file:
这个超时是茉莉花测试不能运行太久。如果你想等待页面上的页面加载和角度更长 - 将其添加到量角器配置文件:
getPageTimeout: timeout_in_millis //default 10 sec
allScriptsTimeout: timeout_in_millis //default 11 sec
More about timeouts here - http://www.protractortest.org/#/timeouts
更多关于超时的信息 - http://www.protractortest.org/#/timeouts
Also check that you point to correct root element:
还要检查是否指向正确的根元素:
// 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',
I would not recomend runnning protractor tests on phantomJS, it works really differently from real browsers, and sometimes you might skip real bugs, or find something specific to phantomJS.
我不打算在phantomJS上推荐runnning量角器测试,它与真正的浏览器有很大不同,有时候你可能会跳过真正的bug,或者找到特定于phantomJS的东西。
#1
1
You increasing wrong timeout:
你增加错误的超时:
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000000;
This timeout is for jasmine test not to run for too long. If you want to wait for page load and angular on the page longer - add this to protractor config file:
这个超时是茉莉花测试不能运行太久。如果你想等待页面上的页面加载和角度更长 - 将其添加到量角器配置文件:
getPageTimeout: timeout_in_millis //default 10 sec
allScriptsTimeout: timeout_in_millis //default 11 sec
More about timeouts here - http://www.protractortest.org/#/timeouts
更多关于超时的信息 - http://www.protractortest.org/#/timeouts
Also check that you point to correct root element:
还要检查是否指向正确的根元素:
// 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',
I would not recomend runnning protractor tests on phantomJS, it works really differently from real browsers, and sometimes you might skip real bugs, or find something specific to phantomJS.
我不打算在phantomJS上推荐runnning量角器测试,它与真正的浏览器有很大不同,有时候你可能会跳过真正的bug,或者找到特定于phantomJS的东西。