Correctly Accessing the browser from retry failed step plugin

Hey all, first post here. Previously I was using Custom Helpers to retry failed steps and it was very simple to use WebDriver helper due to Helpers being child classes of codecept_helper, this was used to intercept different failure scenarios and perform an action to mitigate the issue before retrying. Now I’ve been moving away to using the retry failed step plugin, and I haven’t been able to figure out how to correctly access the browser, I tried quite a few ways, but nothing was consistent.

Current example config:

{
    enabled: true,
    retries: 2,
    minTimeout: 2000,
    when: function(err) {
        if (err.name == 'element click intercepted') {
            //access the browser and get rid of intercepting element before retrying
        }
        return true;
    }
}

Any help or suggestion would be appreciated, thanks :slight_smile:

sorry, this is the biggest limitation of retryFailedStep plugin so far.
if we will solve this, we will enable it by default. So far it has its problems :frowning:

Thanks for the swift response, I’ll see if I can come up with some alternatives, thanks :+1:

Hey @davert this isn’t the prettiest, but works… I can load in WebDriver itself from the container and perform certain actions:

const Container = require('codeceptjs').container;

module.exports = {
    enabled: true,
    retries: 1,
    minTimeout: 2000,
    when: async function(err) {

        const browser = Container.helpers()['WebDriver']['browser'];

        if (err.name == 'element click intercepted') {

            const element = await browser.findElement('css selector', '.intercepting-element-dismiss-selector');
            const elementId = Object.values(element)[0];
            await browser.elementClick(elementId);
        }
        return true;
    }
};

Hope this helps anyone looking for solutions to this

1 Like