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:
Failed: Angular could not be found on the page URL : retries looking for angular exceeded
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
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
sudo apt-get install phantomjs
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With