angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Intermittent failure to detect elements (or waiting for elements) after upgrading Chrome version #4564

Open tediroca opened 6 years ago

tediroca commented 6 years ago

Bug report

var HtmlScreenshotReporterModule = require('protractor-jasmine2-screenshot-reporter');
var xmlReporterModule = require('jasmine-reporters');
var ConsoleReporterModule = require('jasmine-spec-reporter').SpecReporter;
var VideoReporterModule = require('protractor-video-reporter');
var Path = require('path');

var consoleReporter = new ConsoleReporterModule({
    spec: {
        displayStacktrace: true
    }
});

var htmlReporter = new HtmlScreenshotReporterModule({
    dest: 'reports/html',
    filename: 'htmlReport.html',
    showSummary: true,
    showQuickLinks: true
});

exports.config = {
    allScriptsTimeout: 2000000,
    directConnect: false,
    suites: {
        someSuite: ['specs/someSuite/*.spec.js']
    },
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {'args': ['lang=en-GB', 'enable-precise-memory-info', 'js-flags=--expose-gc', 'no-sandbox']}
        //shardTestFiles: true,
        //maxInstances: 3
    },
    baseUrl: 'https://someUrl',
    framework: 'jasmine2',
    restartBrowserBetweenTests: false,
    beforeLaunch: function () {
        return new Promise(function (resolve) {
            htmlReporter.beforeLaunch(resolve);
        });
    },
    onPrepare: function () {
        browser.manage().window().setSize(1920, 1080);
        jasmine.getEnv().addReporter(new xmlReporterModule.JUnitXmlReporter({
            consolidateAll: true,
            filePrefix: 'results',
            savePath: 'reports/xml'
        }));

        jasmine.getEnv().addReporter(htmlReporter);
        jasmine.getEnv().addReporter(consoleReporter);

        jasmine.getEnv().addReporter(new VideoReporterModule({
            baseDirectory: Path.join(__dirname, 'reports/videos/'),
            singleVideo: false,
            ffmpegArgs: [
                '-y',
                '-r', '30',
                '-f', 'x11grab',
                '-s', '1920x1080',
                '-i', process.env.DISPLAY,
                '-g', '300',
                '-vcodec', 'qtrle'
            ]
        }));

    },
    afterLaunch: function (exitCode) {
        return new Promise(function (resolve) {
            htmlReporter.afterLaunch(resolve.bind(this, exitCode));
        });
    },
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 2500000,
        isVerbose: true,
        includeStackTrace: true,
        realtimeFailure: true,
        print: function () {
        }
    }
};

The error refers to the line:

browser.wait(EC.visibilityOf(element(by.id("loggedInUser"))), 50000);

The scenario above is just one example of multiple tests what were successfully executed daily in CI environment. Not sure what started to cause the problem but to me it feels like sometimes Protractor is not waiting for a previous step to complete (or a previous promise to be resolved) before trying to locate the element that cause the problem.

It also seems to be noticeable on parts of the UI that change. E.g. step 1 in Protractor clicks a checkbox that enables an additional section in the UI and step 2 interacts with this new section. At this stage Protractor fails waiting or locating the new section since it tries to interact with it just straight after clicking on the checkbox.

Other relevant info is that most of the tests fail when run headless on the CI server (Linux) but all the specs pass successfully if I ran them in my laptop with exactly the same Chromdriver, Protractor and Chrome versions, but using Windows 10 instead of Linux.

wswebcreation commented 6 years ago

I know there is also an issue listed with problems on Linux and latest Chrome, and no problems with older versions / other OS / Browser combinations.

Have you also checked ChromDriver? I think it's more a bug there then in Protractor

tediroca commented 6 years ago

Have you also checked ChromDriver? I think it's more a bug there then in Protractor

I went through the open tickets in the Chromedriver tracker but I couldn't find anything that relates to this problem.

wswebcreation commented 6 years ago

Maybe you can file one with a testcase for it

tediroca commented 6 years ago

I had already raised a ticket for the Chromedriver. For the time being I have downgraded Chrome to the previous version (61) and all specs are working fine.

https://bugs.chromium.org/p/chromedriver/issues/detail?id=2105

wswebcreation commented 6 years ago

@tediroca

Tnx, will you also give feedback in this issue when you have more info on the filled bug?

tediroca commented 6 years ago

Sure. I'll update this ticket as soon as we get more info.

tediroca commented 6 years ago

This issue does no longer happen with Protractor 5.3.0, Chromedriver 2.35 and Chrome 64.

Not sure if this is fully fixed since the ticket that I had raised in the Chromedriver tracker has been closed as Won't fix.

https://bugs.chromium.org/p/chromedriver/issues/detail?id=2105#c13