Serenity-js: Photographer: async operations have failed to complete within a 5s cue timeout

Created on 4 Dec 2020  Â·  3Comments  Â·  Source: serenity-js/serenity-js

Hi,

I have a test that I run on Saucelabs and I want to take screenshots of this test. Here is my protractor configuration where I configure it to take screenshots of all interactions:

const
    { ArtifactArchiver } = require('@serenity-js/core'),
    { ConsoleReporter } = require('@serenity-js/console-reporter'),
    { Photographer, TakePhotosOfInteractions } = require('@serenity-js/protractor'),
    { SerenityBDDReporter } = require('@serenity-js/serenity-bdd');

exports.config = {

    sauceUser: 'my sauce user here',
    sauceKey: 'my sauce key here',
    sauceBuild: 'test-protractor',

    SELENIUM_PROMISE_MANAGER: false,
    allScriptsTimeout: 110000,

    framework: 'custom',
    frameworkPath: require.resolve('@serenity-js/protractor/adapter'),

    specs: ['./spec/*/*.spec.ts',],

    serenity: {
        runner: 'jasmine',
        crew: [
            ArtifactArchiver.storingArtifactsAt('./build/reports/serenity'),
            ConsoleReporter.forDarkTerminals(),
            Photographer.whoWill(TakePhotosOfInteractions),
            new SerenityBDDReporter(),
        ]
    },

    onPrepare: function() {
        browser.waitForAngularEnabled(false);
    },

    jasmineNodeOpts: {
        requires: ['ts-node/register'],
    },

    capabilities: {
        shardTestFiles: true,
        maxInstances: 10,

        loggingPrefs: {
            browser: 'ALL'
        },

        browserName: 'chrome',
        platform: 'Windows 10',
        browserVersion: 'latest',
        recordScreenshots: 'false',
        screenResolution: '1920x1080',
        'sauce:options': {
            'screenResolution': '1920x1080',
            'recordScreenshots': 'false',
            'timeout': '360000',
            'implicit.wait': '10000',
            'idleTimeout': '600'
        }
    }
};

When I run my test I get following issue:

[test:execute] ✗ Execution failed with error (13s 389ms)
[test:execute] 
[test:execute]   Error: 1 async operation has failed to complete within a 5s cue timeout:
[test:execute]   5s 6ms - [Photographer:TakePhotosOfInteractions] Taking screenshot of 'New customer clicks on the get started button'...
[test:execute]       at Timeout._onTimeout (/home/acranga/myprojects/serenity-js-jasmine-protractor-template/node_modules/@serenity-js/core/src/stage/StageManager.ts:48:35)
[test:execute]       at listOnTimeout (internal/timers.js:554:17)
[test:execute]       at processTimers (internal/timers.js:497:7)

Here is a very simple spec I created to reproduce this on https://serenity-js.org/ site:

import 'jasmine';

import { actorCalled, engage, Duration } from '@serenity-js/core';
import { Navigate, Wait, isVisible, Click, Target } from '@serenity-js/protractor';
import { by } from 'protractor';
import { Actors } from '../../src';

class SerenityJs {
    static getStartedButton = Target.the('get started button')
        .located(by.css('.btn-accent-1'));
}

describe('photographer fails to capture screenshots', () => {
    beforeEach(() => engage(new Actors()));

    it(`waits for button visibility`, () =>
        actorCalled('New customer').attemptsTo(
            Navigate.to('https://serenity-js.org'),
            Wait.upTo(Duration.ofSeconds(10)).until(SerenityJs.getStartedButton, isVisible()),
            Click.on(SerenityJs.getStartedButton)
        ));
});

As far as I can see, it fails to capture screenshots on Wait.upTo step.

Could someone please take a look?

Thank you!

EDIT:
tested this same scenario locally in chrome browser, works as expected without any failures

EDIT:
tried to use

Check.whether(SerenityJs.getStartedButton, isVisible()).andIfSo(Click.on(SerenityJs.getStartedButton))

but it does not wait for element to become visible

documentation question

Most helpful comment

Hi @alexanderkranga and welcome the Serenity/JS community :-)

The "stage cue timeout" describes how long Serenity/JS will wait for any asynchronous operations performed by its StageCrewMembers to complete.

Photographer is one such StageCrewMember, and in the case of your test suite it's configured to take screenshots of every single interaction the Actors perform. Since the screenshots are taken in a browser running on SauceLabs, I am guessing it might take longer than the default timeout of 5 seconds to download the screenshots from a remote service.

[test:execute]   Error: 1 async operation has failed to complete within a 5s cue timeout:
[test:execute]   5s 6ms - [Photographer:TakePhotosOfInteractions] Taking screenshot of 'New customer clicks on the get started button'...

Have you tried increasing the cueTimeout or configuring Photographer to TakePhotosOfFailures when running against SauceLabs?

// protractor.conf.js

const
    { ArtifactArchiver, Duration } = require('@serenity-js/core'),
    { ConsoleReporter } = require('@serenity-js/console-reporter'),
    { Photographer, TakePhotosOfInteractions } = require('@serenity-js/protractor'),
    { SerenityBDDReporter } = require('@serenity-js/serenity-bdd');

// ...

    serenity: {
        runner: 'jasmine',
        cueTimeout: Duration.ofSeconds(10),
        crew: [
            ArtifactArchiver.storingArtifactsAt('./build/reports/serenity'),
            ConsoleReporter.forDarkTerminals(),
            Photographer.whoWill(TakePhotosOfInteractions),
            new SerenityBDDReporter(),
        ]
    },

All 3 comments

Hi @alexanderkranga and welcome the Serenity/JS community :-)

The "stage cue timeout" describes how long Serenity/JS will wait for any asynchronous operations performed by its StageCrewMembers to complete.

Photographer is one such StageCrewMember, and in the case of your test suite it's configured to take screenshots of every single interaction the Actors perform. Since the screenshots are taken in a browser running on SauceLabs, I am guessing it might take longer than the default timeout of 5 seconds to download the screenshots from a remote service.

[test:execute]   Error: 1 async operation has failed to complete within a 5s cue timeout:
[test:execute]   5s 6ms - [Photographer:TakePhotosOfInteractions] Taking screenshot of 'New customer clicks on the get started button'...

Have you tried increasing the cueTimeout or configuring Photographer to TakePhotosOfFailures when running against SauceLabs?

// protractor.conf.js

const
    { ArtifactArchiver, Duration } = require('@serenity-js/core'),
    { ConsoleReporter } = require('@serenity-js/console-reporter'),
    { Photographer, TakePhotosOfInteractions } = require('@serenity-js/protractor'),
    { SerenityBDDReporter } = require('@serenity-js/serenity-bdd');

// ...

    serenity: {
        runner: 'jasmine',
        cueTimeout: Duration.ofSeconds(10),
        crew: [
            ArtifactArchiver.storingArtifactsAt('./build/reports/serenity'),
            ConsoleReporter.forDarkTerminals(),
            Photographer.whoWill(TakePhotosOfInteractions),
            new SerenityBDDReporter(),
        ]
    },

@jan-molak thank you for your detailed response, I really appreciate it. I tested increasing the cueTimeout to 10and it works great, thank you again!

Excellent, thanks for letting me know! Enjoy Serenity 😊

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jan-molak picture jan-molak  Â·  4Comments

mrj04 picture mrj04  Â·  3Comments

GeeChao picture GeeChao  Â·  6Comments

marktigno picture marktigno  Â·  4Comments

AbhineetSharmax picture AbhineetSharmax  Â·  4Comments