当我执行protractor protractor.conf.js --baseUrl=http://localhost:4200/
,它工作得很好-填充数据,验证元件等
当我通过尝试测试完全相同的网站远程URL protractor protractor.conf.js --baseUrl=http://the-same-website.com/
,它在浏览器,登录打开了所有必要的零部件都加载像本地主机,但量角器/茉莉花不补/点击/验证什么,我得到指定的时间后超时:
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
- Failed: script timeout: result was not received in 30 seconds
(Session info: chrome=71.0.3578.98)
还有其他的线程将在堆栈溢出类似的问题-试图browser.ignoreSynchronization = true
和Protractor.waitForAngular(false)
,但随后网页不能正常加载和测试失败,因为元素都没有发现。
更新1
下面以及在本地主机上的作品的试验 - 根据H1,但在远程URL它不检查,尽管网络的任何输出成功或失败加载:
import { browser, by, element } from 'protractor';
describe('example-test', () => {
const PATH_TO_TEST = 'specific-path/to/test';
beforeEach(() => {
browser.get(PATH_TO_TEST);
});
it('should exist header', () => {
expect(element(by.css('h1')).getText()).toEqual('test');
});
});
如果我添加日志记录,我看到的产量,但expect
不执行:
import { browser, by, element } from 'protractor';
describe('example-test', () => {
const PATH_TO_TEST = 'specific-path/to/test';
beforeEach(() => {
browser.get(PATH_TO_TEST);
console.log('beforeEach');
});
it('should exist header', () => {
expect(element(by.css('h1')).getText()).toEqual('test');
console.log('test end');
});
});
量角器配置:
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 30000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
}
更新2
如果我添加browser.sleep
和browser.ignoreSynchronization
,测试开始工作,但后来我需要添加browser.sleep
每一个同步不好看:
beforeEach(() => {
browser.get('path/to/test');
browser.sleep(3000);
browser.ignoreSynchronization = true;
});
看来,作为满载或斜网量角器不承认页。
为什么尽管页面被正确加载量角器不验证内容?