This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Error when creating a Protractor Plugin: Error while waiting for Protractor to sync with the page: both angularJS testability and angular testability are undefined. #5461
Open
Description
- Node Version:
10.16.3 - Protractor Version:
5.4.0and7.0.0 - Angular Version:
7.2.0 - Browser(s):
chrome - Operating System and Version
Windows 10 pro - Your protractor configuration file
const { SpecReporter } = require('jasmine-spec-reporter');
const capturePromises = [];
exports.config = {
plugins: [
{
inline: {
name: 'ProtractorTest',
postTest: (passed, testInfo) => {
console.log('postTest');
const p = capture(testInfo.name);
capturePromises.push(p);
},
teardown: () => {
// Wait for promises to finish
return Promise.all(capturePromises);
}
}
}
],
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [
'--headless',
'--no-sandbox',
'--disable-gpu',
'--disable-software-rasterizer',
'--disable-extensions',
'--disable-dev-shm-usage',
'--test-type=browser',
'--window-size=1400,1000'
]
}
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
function capture(description) {
return new Promise((resolve, reject) => {
console.log('takeScreenshot() before', description);
browser.takeScreenshot().then((pngBase64) => {
console.log('takeScreenshot() after', description);
console.log('getPageSource() before', description);
browser.getPageSource().then((pageSource) => {
console.log('getPageSource() after', description);
resolve();
}, (err) => {
console.log('getPageSource() err', description);
reject(err);
});
}, (err) => {
console.log('takeScreenshot() err', err);
reject(err);
});
});
}
- A relevant example test
import { $$, browser } from 'protractor';
const url = 'https://about.google/';
describe('suite alpha', () => {
beforeAll(async () => {
await browser.get(url);
});
it('first test', async () => {
const text = await $$('h2').get(0).getText();
console.log('text first', text);
});
});
describe('suite beta', () => {
beforeAll(async () => {
await browser.get(url);
});
it('second test', async () => {
const text = await $$('h2').get(0).getText();
console.log('text second', text);
});
});
- Output from running the test
[09:04:56] I/launcher - Running 1 instances of WebDriver
[09:04:56] I/direct - Using ChromeDriver directly...
Jasmine started
text first Company news
postTest
takeScreenshot() before first test
suite alpha
√ first test
takeScreenshot() after first test
getPageSource() before first test
getPageSource() err first test
(node:7428) UnhandledPromiseRejectionWarning: Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at runWaitForAngularScript.then (C:\dev\temp\angular-plugin-test\node_modules\protractor\built\browser.js:463:23)
at ManagedPromise.invokeCallback_ (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:7428) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7428) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
text second Company news
postTest
takeScreenshot() before second test
suite beta
√ second test
Executed 2 of 2 specs SUCCESS in 4 secs.
[09:05:04] I/plugins - Fail: ProtractorTest Plugin Tests
[09:05:04] E/plugins - Failure during teardown: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
[09:05:04] E/plugins - Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at runWaitForAngularScript.then (C:\dev\temp\angular-plugin-test\node_modules\protractor\built\browser.js:463:23)
at ManagedPromise.invokeCallback_ (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\dev\temp\angular-plugin-test\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:7428) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
takeScreenshot() after second test
getPageSource() before second test
[09:05:04] I/launcher - 0 instance(s) of WebDriver still running
[09:05:04] I/launcher - chrome #01 failed 1 test(s)
[09:05:04] I/launcher - overall: 1 failed spec(s)
[09:05:04] E/launcher - Process exited with error code 1
- Steps to reproduce the bug
./node_modules/protractor/bin/protractor e2e/protractor.conf.js --specs e2e/src/app.e2e-spec.t
- The URL you are running your tests against (if relevant)
The error does not happen when there is only one describe() in the spec file.
The error does not happen when plugin is removed.
The error does not happen when only one of browser.takeScreenshot() or browser.getPageSource() is called in capture().
The error does not happen when browser.getPageSource() is called before browser.takeScreenshot() in capture().
Metadata
Metadata
Assignees
Labels
No labels

