所以我一直试图在我的Angular 4.4.6项目中使用量角器来测试模板驱动器表单。
我按照他们网站上的量角器设置说明进行操作。
的package.json
"dependencies": {
"@angular/common": "^4.4.6",
"@angular/compiler": "^4.4.6",
"@angular/core": "^4.4.6",
"@angular/forms": "^4.4.6",
"@angular/http": "^4.4.6",
"@angular/platform-browser": "^4.4.6",
"@angular/platform-browser-dynamic": "^4.4.6",
"@angular/router": "^4.4.6",
"@types/selenium-webdriver": "^3.0.8",
"core-js": "2.5.1",
"json-typescript-mapper": "^1.1.3",
"rxjs": "^5.5.0",
"typings": "^2.1.1",
"zone.js": "^0.8.18"
},
"devDependencies": {
"protractor": "^5.0.0"
}
protractor.conf.js
require('ts-node/register');
const helpers = require('./helpers');
exports.config = {
baseUrl: 'http://localhost:3000/',
specs: [
helpers.root('src/**/**.e2e.ts'),
helpers.root('src/**/*.e2e.ts')
],
framework: 'jasmine',
allScriptsTimeout: 11000,
jasmineNodeOpts: {
showTiming: true,
showColors: true,
isVerbose: false,
includeStackTrace: false,
defaultTimeoutInterval: 40000
},
directConnect: true,
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=800x600", "--no-sandbox" ]
}
},
onPrepare: function() {
browser.ignoreSynchronization = true;
require("zone.js/dist/zone-node");
require('ts-node').register({
project: 'tsconfig.e2e.json'
});
}
SELENIUM_PROMISE_MANAGER: false
};
我尝试了很多方法来获取我的网页的网址。
这是一个示例代码。
import {browser, by, element} from 'protractor';
describe('General Info Component End to End', () => {
beforeEach(() => {
browser.waitForAngular();
browser.get('asdfasdf, 3000);
});
it('should return page title', () => {
element.all(by.css('#effective-date')).sendKeys('01/01/2018');
expect(element.all(by.css('#effective-date')).getAttribute('value')).toContain('01/01/2018');
});
});
这过去了,不应该这样。
答案 0 :(得分:0)
要获取当前页面网址,您需要使用browser.getCurrentUrl()
,您的browser.get函数调用似乎也缺少单引号