Я пытаюсь использовать restartBrowserBetweenTests внутри моей конфигурации и запускаю следующую ошибку: NoSuchSessionError: Этот экземпляр драйвера не имеет действительного идентификатора сеанса (вы вызывали WebDriver.quit ()?) И больше не может использоваться
Я использую транспортир, машинопись, огурец, селен
"protractor": "^5.4.3",
"protractor-cucumber-framework": "^6.2.0",
protractor.conf.ts
import { Config, browser } from 'protractor';
import { Reporter } from 'tal-protractor-common';
import * as path from 'path';
import * as e2eConf from './e2e.conf';
import { setStructureUrl } from './e2e.conf';
const basePath = path.join(process.cwd(), './e2e/support/dashboard/reports');
const rep: Reporter = new Reporter(basePath);
const jsonReports = process.cwd() + './e2e/support/dashboard/reports';
export let config: Config = {
// Basic Info
baseUrl: Https:example.....,
// Cucumber Config
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
require: ['step_definitions/**/*.js'],
// tags: '~@Ignore',
format: 'json:./e2e/support/dashboard/reports/json/cucumber_report.json',
strict: true
},
// Protractor & Browser Config
SELENIUM_PROMISE_MANAGER: false,
restartBrowserBetweenTests: true,
directConnect: true,
multiCapabilities: [{
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--window-size=1440,1200', 'lang=en-us']
},
cucumberOpts: {
require: ['step_definitions/**/*.js'],
// tags: '~@Ignore',
format: 'json:./e2e/support/dashboard/reports/json/cucumber_report.chrome.json',
strict: true
}
},
{
'browserName': 'firefox',
'moz:firefoxOptions': {
args: ['--headless', 'lang=en-us']
},
'cucumberOpts': {
require: ['step_definitions/**/*.js'],
// tags: '~@Ignore',
format: 'json:./e2e/support/dashboard/reports/json/cucumber_report.firefox.json',
strict: true
}
}],
// Timeouts
allScriptsTimeout: 20000,
getPageTimeout: 20000,
setDefaultTimeout: (20000),
specs: ['features/*.feature'],
suites: {
fullRegression: [
'features/header.feature',
'features/stepper.feature'
]
},
onPrepare: async () => {
browser.driver.manage().window().setSize(1440, 1200);
await browser.manage().timeouts().implicitlyWait(0);
browser.waitForAngularEnabled(false);
browser.driver.getCapabilities().then(function (caps) {
browser.browserName = caps.get('browserName');
});
rep.createDirectory(jsonReports);
},
onComplete: () => {
rep.createHTMLReport();
},
};
На моих крючках. TS
import { browser } from 'protractor';
import { BeforeAll, Before, After, AfterAll, setDefaultTimeout, Status } from 'cucumber';
import { expect, Helpers } from 'tal-protractor-common';
import { config } from '../protractor.conf';
import { StepperCommonPage } from '../page-objects/stepper-common-page';
import { StorageHelpers } from '../support/storage-helpers';
import { CookiesHelpers } from '../support/cookies-helpers';
import { E2E_STATE_KEY, E2E_STATE_KEY_ST } from '../e2e.conf';
import * as packageJson from '../../package.json';
// New Instances
const helpers: Helpers = new Helpers();
const storageHelpers: StorageHelpers = new StorageHelpers();
const cookiesHelpers: CookiesHelpers = new CookiesHelpers();
const stepperCommon: StepperCommonPage = new StepperCommonPage();
let startTime: number;
let endTime: number;
BeforeAll({timeout: 20 * 1000},
async () => {
startTime = helpers.timeNow();
setDefaultTimeout(20 * 1000);
await browser.get(config.baseUrl);
browser.ignoreSynchronization = false;
await helpers.waitForInvisibilityOf(stepperCommon.loadingSpinner);
// tslint:disable-next-line
await browser.executeScript('let agentPrefix=arguments[0];let currentAgent=navigator.userAgent;navigator.__defineGetter__("userAgent",function(){return agentPrefix + currentAgent})',
config.userAgentPrefix);
let testedUserAgent = await browser.executeScript('return navigator.userAgent');
await expect(testedUserAgent).to.include(config.userAgentPrefix);
});
After(async function (scenario) {
if (scenario.result.status === Status.FAILED) {
// screenShot is a base-64 encoded PNG
const screenShot = await browser.takeScreenshot();
this.attach(screenShot, 'image/png');
}
await storageHelpers.clearLocalStorage();
await cookiesHelpers.updateCookie();
});
AfterAll(
async () => {
endTime = helpers.timeNow();
process.env.E2E_ELAPSED_TIME = helpers.calculateElapsedTime(endTime, startTime);
});
export class States {
public async setState(context) {
// Set Current Version to Context
let packageJsonBody: any = packageJson;
context.app.version = packageJsonBody.version;
// Set Context
let pageUrl = await browser.getCurrentUrl();
if (pageUrl.includes('localhost')) {
await browser.executeScript(`window.localStorage.setItem("${E2E_STATE_KEY}", arguments[0])`, context);
} else {
await browser.executeScript(`window.localStorage.setItem("${E2E_STATE_KEY_ST}", arguments[0])`, context);
}
await browser.refresh();
await helpers.relax();
}
}
При выполнении некоторых тестов запуска NoSuchSessionError: Этот экземпляр драйвера не имеет действительный идентификатор сеанса (вы вызывали WebDriver.quit ()?) и больше не может использоваться