import {Browser} from '@serenity-js/protractor/lib/screenplay/questions'
public class | source

Browser

Static Method Summary

Static Public Methods
public static

log(): Question<Promise<logging.Entry[]>>

Creates a Question that reads the entries of the browser log so that they can be asserted on.

Static Public Methods

public static log(): Question<Promise<logging.Entry[]>> source

Creates a Question that reads the entries of the browser log so that they can be asserted on.

Please note that in order to ensure that the automated test has access to the browser log, Protractor needs to be configured with the desired logging level, as per the example below.

Returns:

Question<Promise<logging.Entry[]>>

Examples:

Enabling Protractor browser logging
// protractor.conf.js
exports.config = {
  capabilities: {
    loggingPrefs: {
        // available options: OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL
        browser: 'SEVERE'
    },
  }
}
Ensure the app didn't log anything to the console during the test
import { Actor, BrowseTheWeb, Browser } from '@serenity-js/core';
import { Ensure, property, equals } from '@serenity-js/assertions';

actor.attemptsTo(
  Ensure.that(Browser.log(), property('length', equals(0))),
);
Mark the test as "compromised" if the server responds with a 500 to any AJAX request during the test
import { Actor, BrowseTheWeb, Browser, TestCompromisedError } from '@serenity-js/core';
import { Ensure, property, equals, not, contrainAtLeastOneItemThat } from '@serenity-js/assertions'

actor.attemptsTo(
  Ensure.that(Browser.log(),
    not(contrainAtLeastOneItemThat(
      property('message', includes('the server responded with a status of 500'))
    ))
  ).otherwiseFailWith(TestCompromisedError, 'The server is down'),
);