我找不到如何在Angular 4中配置browserStack。
这是我在protactor.conf中的实际内容
运行localy的命令
ng e2e --serve false --port 4200 --host dev.fastshop.com.br
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
browserName: 'chrome',
'chromeOptions': {
'args': [
// here disable crome visual
// '--headless',
// '--disable-gpu',
'--user-data-dir=~/e2e-chrome-profile',
'--disable-web-security',
'--window-size=1920,1080',
],
}
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 60000,
print: function () { }
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
强文
答案 0 :(得分:0)
以下是与您最新的Angular内联的示例
/* eslint-disable */
const basePath = __dirname;
const { SpecReporter } = require('jasmine-spec-reporter');
const getSpecs = (listSpec) => {
if (listSpec) {
return listSpec.split(',');
}
return ['samples/**/*.e2e-spec.js', 'sample-test.e2e-spec.js'];
};
const theme = 'light'
exports.config = {
params: {
theme
},
allScriptsTimeout: 12000,
logLevel: 'INFO',
specs: getSpecs(process.env.PROTRACTOR_SPECS),
seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub',
SELENIUM_PROMISE_MANAGER: false,
baseUrl: 'http://localhost:8080/',
jasmineNodeOpt: {
defaultTimeoutInterval: 10000,
showColors: true,
random: false
},
commonCapabilities: {
'browserstack.user': process.env.BROWSER_STACK_USERNAME,
'browserstack.key': process.env.BROWSER_STACK_ACCESS_KEY,
'browserstack.debug': false,
'browserstack.video' : 'false',
'browserstack.local': false,
'browserstack.selenium_version': '3.11.0',
'browserstack.networkLogs' : false,
build: `${theme} theme: ci e2e`,
name: `${theme} theme ci e2e tests`
},
multiCapabilities: [
{
browserName: 'Chrome',
browser_version: '66.0',
resolution: '1280x800',
os_version: '10',
os: 'Windows'
},
{
browserName: 'Chrome',
browser_version : '66.0',
os: 'OS X',
os_version: 'High Sierra',
resolution: '1280x960'
}
],
onPrepare: () => {
global.requireHelper = (filename) => require(`${basePath}/helpers/${filename}.js`);
browser.ignoreSynchronization = true;
jasmine.getEnv().addReporter(new SpecReporter({
spec: { displayStacktrace: true }
}));
return browser.getProcessedConfig().then((cap) => {
browser.browserName = cap.capabilities.browserName.toLowerCase();
if (browser.browserName === 'chrome') {
return browser.driver.manage().window().setSize(1200, 800);
}
});
}
};
exports.config.multiCapabilities.forEach((caps) => {
for (const i in exports.config.commonCapabilities) {
caps[i] = caps[i] || exports.config.commonCapabilities[i];
}
});
配置使用2个浏览器实例,Windows上的Chrome和OS X上的Chrome