Open JonWallsten opened 5 years ago
Looking at your sample test, it is working as expected only. Every time you call browser logs, after fetching the array will be empty only. You are fetching the log from the browser inside your test. It fetches all the log messages. When you call the browser logs again it will be null.
But if I remove the code inside the test case it's still empty in the afterEach hook. And besides they both give me a result in chrome if I'm not running headless. So I think you're wrong.
Bug Report
We're trying to store the browser log after each test case, but when we try to access the log in the afterEach hook the log is already emptied. It just returns an empty array. When fetching the log in the end of the test case though, it returns the messages. So there seems to be a race condition or something. Unfortunately I don't have the knowledge to deduct if the error is in Protractor, Selenium, Chrome Headless or Chromedriver. Maybe someone here has that knowledge?
Edit: I added a breakpoint in the Logs.get method in selenium webdriver. Entries are indeed empty when I try to collect the logs in the afterEach-hook.
v10.9.0
5.4.2
1.5.x/7.x.x
Chromium (Puppeteer) (Headless)
Window 10
let puppeteer = null; if(process.env.HEADLESS) { puppeteer = require('puppeteer'); }
const consoleReporter = new JasmineConsoleReporter({ colors: process.env.IS_DEV ? 1 : 0, cleanStack: 1, verbosity: 4, listStyle: 'indent', activity: false });
const screenshotReporter = new HtmlScreenshotReporter({ dest: helpers.htmlReportDir, filename: 'test-report.html', reportOnlyFailedSpecs: false, captureOnlyFailedSpecs: true });
const junitReporter = new jasmineReporters.JUnitXmlReporter({ savePath: helpers.junitReportDir, consolidateAll: false });
exports.config = { framework: 'jasmine', chromeDriver: chromeDriverPath, multiCapabilities: [{ browserName: 'chrome', chromeOptions: { args: process.env.HEADLESS && puppeteer ? ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--window-size=1920,1200', '--disable-setuid-sandbox', '--auth-server-whitelist=*scania.com'] : [], binary: process.env.HEADLESS && puppeteer ? puppeteer.executablePath() : undefined } }], getPageTimeout: 90000, // How long to wait for a page to load allScriptsTimeout: 90000, // The timeout in milliseconds for each script run on the browser. This should be longer than the maximum time your application needs to stabilize between tasks.
};
const addSpecNameToBrowserLog = { specStarted: (result) => { 'use strict'; fs.appendFileSync(helpers.testResultDir + 'browser_output.log',
#${result.description} ${nodeOS.EOL}
); } };import { browser } from 'protractor';
describe('Tests', () => {
});