量角器 - 只有当我将鼠标移到浏览器上时,E2E 测试才会开始 window 每个 Cucumber 场景
Protractor - E2E testing starts only when I move the mouse over the browser window for each Cucumber scenario
我正在开发一个 Angular 6/Protractor/Cucumber 应用程序,当我启动 E2E 测试时它只会在我将鼠标移到浏览器上时启动 window(对于每个 Cucumber 场景).
我的 protractor.conf.js
exports.config = {
allScriptsTimeout: 100000,
capabilities: {
'browserName': 'chrome'
},
multiCapabilities: [
{
browserName: 'chrome',
specs: 'e2e/features/*.feature'
}
],
directConnect: true,
baseUrl: 'http://localhost:4201/',
// Use a custom framework adapter and set its relative path
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
// cucumber command line options
cucumberOpts: {
// require step definition files before executing features
require: ["supports/timeout.js", './e2e/steps/**/*.ts', './cucumber/*.js'],
// <string[]> (expression) only execute the features or scenarios with tags matching the expression
tags: [],
// <boolean> fail if there are any undefined or pending steps
strict: true,
// <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
format: [
'json:e2e/reports/summary.json'
],
// <boolean> invoke formatters without executing steps
dryRun: false,
// <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
compiler: []
},
// Enable TypeScript for the tests
onPrepare() {
require('ts-node').register({
project: './e2e/tsconfig.e2e.json'
});
},
};
以及步骤示例:
import {Before, Given} from 'cucumber';
import {browser} from 'protractor';
import {StepsUtils} from '../utils';
const {setDefaultTimeout} = require('cucumber');
Before(() => {
setDefaultTimeout(60 * 15000);
});
Given('J\'ouvre Google Chrome en mode plein écran', function () {
StepsUtils.navigateToRoot();
browser.manage()
.window()
.maximize()
.catch(ignoreVoid => {
return;
});
return browser.getTitle();
});
浏览器已最大化,但在我将鼠标移到浏览器上之前不会执行后续步骤。如果我不将鼠标移到控制台上,则会显示以下错误:
E/launcher - script timeout: result was not received in 100 seconds
(Session info: chrome=69.0.3497.100)
我已经通过这样做解决了问题:
在打开浏览器之前,我将 waitForAngularEnabled 设置为 false,然后在对应用程序进行身份验证后,我将其设置回 true。
更改 waitForAngularEnabled 的值是通过以下方法实现的:
browser.waitForAngularEnabled(true);
我正在开发一个 Angular 6/Protractor/Cucumber 应用程序,当我启动 E2E 测试时它只会在我将鼠标移到浏览器上时启动 window(对于每个 Cucumber 场景). 我的 protractor.conf.js
exports.config = {
allScriptsTimeout: 100000,
capabilities: {
'browserName': 'chrome'
},
multiCapabilities: [
{
browserName: 'chrome',
specs: 'e2e/features/*.feature'
}
],
directConnect: true,
baseUrl: 'http://localhost:4201/',
// Use a custom framework adapter and set its relative path
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
// cucumber command line options
cucumberOpts: {
// require step definition files before executing features
require: ["supports/timeout.js", './e2e/steps/**/*.ts', './cucumber/*.js'],
// <string[]> (expression) only execute the features or scenarios with tags matching the expression
tags: [],
// <boolean> fail if there are any undefined or pending steps
strict: true,
// <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
format: [
'json:e2e/reports/summary.json'
],
// <boolean> invoke formatters without executing steps
dryRun: false,
// <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
compiler: []
},
// Enable TypeScript for the tests
onPrepare() {
require('ts-node').register({
project: './e2e/tsconfig.e2e.json'
});
},
};
以及步骤示例:
import {Before, Given} from 'cucumber';
import {browser} from 'protractor';
import {StepsUtils} from '../utils';
const {setDefaultTimeout} = require('cucumber');
Before(() => {
setDefaultTimeout(60 * 15000);
});
Given('J\'ouvre Google Chrome en mode plein écran', function () {
StepsUtils.navigateToRoot();
browser.manage()
.window()
.maximize()
.catch(ignoreVoid => {
return;
});
return browser.getTitle();
});
浏览器已最大化,但在我将鼠标移到浏览器上之前不会执行后续步骤。如果我不将鼠标移到控制台上,则会显示以下错误:
E/launcher - script timeout: result was not received in 100 seconds
(Session info: chrome=69.0.3497.100)
我已经通过这样做解决了问题:
在打开浏览器之前,我将 waitForAngularEnabled 设置为 false,然后在对应用程序进行身份验证后,我将其设置回 true。
更改 waitForAngularEnabled 的值是通过以下方法实现的:
browser.waitForAngularEnabled(true);