问题
i have this error :
- Failed: unknown error: angular is not defined
(Session info: chrome=62.0.3202.94)
(Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.10.0-20-generic x86_64)
when i execute my e2e tests when i use sendKeys
:
return element(by.model('email')).sendKeys('mike@test.test');
package.json :
{
"name": "app",
"version": "0.0.0",
"license": "",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-i18n-dev": "rm -rf dist && for lang in ar de en es fr it ja zh; do ng build --output-path=dist/$lang --aot --bh /$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --locale=$lang --environment=dev ; done",
"build-i18n-demo": " for lang in ar de en es fr it ja zh; do ng build --output-path=dist/$lang --aot --bh /$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --locale=$lang --environment=demo ; done",
"build-i18n-staging": " for lang in ar de en es fr it ja zh; do ng build --output-path=dist/$lang --aot --bh /$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --locale=$lang --environment=staging ; done",
"build-i18n-qa1": " for lang in ar de en es fr it ja zh; do ng build --output-path=dist/$lang --aot --bh /$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --locale=$lang --environment=qa1 ; done",
"build-i18n-qa2": " for lang in ar de en es fr it ja zh; do ng build --output-path=dist/$lang --aot --bh /$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --locale=$lang --environment=qa2 ; done",
"build-i18n-qa3": " for lang in ar de en es fr it ja zh; do ng build --output-path=dist/$lang --aot --bh /$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --locale=$lang --environment=qa3 ; done",
"build-i18n-prod": " for lang in ar de en es fr it ja zh; do ng build --output-path=dist/$lang --aot --bh /$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --locale=$lang --environment=prod ; done",
"e2e": " ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=dev",
"e2e-dev": " ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=dev",
"e2e-dev:watch": " ng e2e --aot --serve true --port 4400 --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=dev --live-reload=true",
"e2e-demo": " Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 && ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=demo",
"e2e-staging": "Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 && ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=staging",
"e2e-qa1": " Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 && ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=qa1",
"e2e-qa2": " Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 && ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=qa2",
"e2e-qa3": " Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 && ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=qa3",
"e2e-prod": " Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 && ng e2e --aot --serve true --port 4200 --watch true --i18n-file=src/locale/messages.en.xlf --i18n-format=xlf --locale=en --base-href /en/ --output-path /en/ --environment=prod",
"test": "ng test --watch false --single-run true --code-coverage true --colors true",
"test-dev": "ng test --watch false --single-run true --code-coverage true --colors true --environment=dev",
"test-demo": "ng test --watch false --single-run true --code-coverage true --colors true --environment=demo",
"test-staging": "ng test --watch false --single-run true --code-coverage true --colors true --environment=staging",
"test-qa1": "ng test --watch false --single-run true --code-coverage true --colors true --environment=qa1",
"test-qa2": "ng test --watch false --single-run true --code-coverage true --colors true --environment=qa2",
"test-qa3": "ng test --watch false --single-run true --code-coverage true --colors true --environment=qa3",
"test-prod": "ng test --watch false --single-run true --code-coverage true --colors true --environment=prod",
"serve-ar": "ng serve --aot --i18n-file=src/locale/messages.ar.xlf --locale=ar --i18n-format=xlf",
"serve-de": "ng serve --aot --i18n-file=src/locale/messages.de.xlf --locale=de --i18n-format=xlf",
"serve-en": "ng serve --aot --i18n-file=src/locale/messages.en.xlf --locale=en --i18n-format=xlf",
"serve-es": "ng serve --aot --i18n-file=src/locale/messages.es.xlf --locale=es --i18n-format=xlf",
"serve-fr": "ng serve --aot --i18n-file=src/locale/messages.fr.xlf --locale=fr --i18n-format=xlf",
"serve-it": "ng serve --aot --i18n-file=src/locale/messages.it.xlf --locale=it --i18n-format=xlf",
"serve-ja": "ng serve --aot --i18n-file=src/locale/messages.ja.xlf --locale=ja --i18n-format=xlf",
"serve-zh": "ng serve --aot --i18n-file=src/locale/messages.zh.xlf --locale=zh --i18n-format=xlf",
"lint": "ng lint",
"xi18n": "ng xi18n --outputPath src/locale",
"doctoc": "doctoc README.md --bitbucket && doctoc doc/README.md --bitbucket --title '**Contents**'",
"tslint": "tslint -c tslint.json -p tsconfig.json 'src/**/*.ts'"
},
"pre-commit": [
"doctoc",
"tslint"
],
"private": true,
"dependencies": {
"@angular/animations": "^5.1.1",
"@angular/common": "^5.1.1",
"@angular/compiler": "^5.1.1",
"@angular/core": "^5.1.1",
"@angular/forms": "^5.1.1",
"@angular/http": "^5.1.1",
"@angular/platform-browser": "^5.1.1",
"@angular/platform-browser-dynamic": "^5.1.1",
"@angular/router": "^5.1.1",
"@types/jquery": "^3.2.17",
"angular2-jwt": "^0.2.3",
"bootstrap-sass": "^3.3.7",
"core-js": "^2.5.3",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"jwt-decode": "^2.2.0",
"ng2-toastr": "^4.1.2",
"raven-js": "^3.21.0",
"rxjs": "^5.5.5",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.6.1",
"@angular/compiler-cli": "^5.1.1",
"@angular/language-service": "^5.1.1",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.94",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"pre-commit": "^1.2.2",
"protractor": "^5.2.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
pageLogin.po.ts
import { browser, element, by, Key } from 'protractor';
export class PageLoginPo {
navigateToLogin() {
return browser.get('/en/login');
}
clickToSubmit() {
return element(by.css('.e2e-btn-submit-sign-in-form')).click();
}
setEmail() {
return element(by.model('email')).sendKeys('mike@test.test');
}
setPassword() {
return element(by.model('password')).sendKeys('mike');
}
emptyEmail() {
return element(by.model('email')).sendKeys('');
}
emptyPassword() {
return element(by.model('password')).sendKeys('');
}
}
pageLogin.e2e-specs.ts
import {PageLoginPo} from './pageLogin.po';
import { browser, Key, element, by } from 'protractor';
describe('View Login', () => {
let page: PageLoginPo;
beforeEach(() => {
page = new PageLoginPo();
page.navigateToLogin();
browser.waitForAngular();
});
});
it('should display error message when i click on submit sign in form without email', () => {
page.emptyEmail();
expect(page.getTextEmailIsRequire()).toEqual('Email is required.');
});
});
Please, can you help me ? thank you for your help :)
来源:https://stackoverflow.com/questions/47814700/failed-unknown-error-angular-is-not-defined