Typescript Conf.ts文件:
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: false
}
}));
return browser.getProcessedConfig()
.then(function(config: any) {
return config.suite;
})
.then(function(suite: any) {
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: suite + '/screenshot'
}).getJasmine2Reporter());
});
}
编译 Conf.js 并尝试运行测试后,错误为:
[09:17:38] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[09:17:39] E/launcher - Error: TypeError: browser.getProcessedConfig is not a function
at onPrepare (Conf.js:42:24)
at q_1.Promise (/usr/local/lib/node_modules/protractor/built/util.js:46:49)
at Function.promise (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:682:9)
答案 0 :(得分:0)
在我的情况下有效:
import { browser, Config } from 'protractor';
// tslint:disable object-literal-sort-keys
export let config: Config = {
directConnect: true,
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 60 * 1000,
showColors: true
},
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 1
},
onPrepare: async () => {
await browser.waitForAngularEnabled(false);
const myConfig = await browser.getProcessedConfig();
console.log('Config');
console.log(myConfig);
...
...
},
SELENIUM_PROMISE_MANAGER: false,
specs: [
'../test/my-test.js'
]
};