Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

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

@tediroca

Description

@tediroca

Bug report

  • Node Version: 7.4.0
  • Protractor Version: 5.2.0
  • Angular Version: 1.4.14
  • Browser(s): Google Chrome Version 62.0.3202.75
  • Operating System and Version CentOS 7
  • Chromedriver version 2.33
  • Your protractor configuration file
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 () {
        }
    }
};
  • A relevant example test
        var EC = protractor.ExpectedConditions;
        browser.wait(EC.visibilityOf(element(by.id("loggedInUser"))), 50000);
        element(by.id("loggedInUser")).click().then(function () {
            element(by.id("logOutLink")).click().then(function () {
                expect(browser.getCurrentUrl()).toMatch("/login");
            });
        });
  • Output from running the test
 �[31m✗ Change expired password feature�[39m
      �[31m- �[39m�[31mFailed: Wait timed out after 50014ms�[39m
          at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2201:17
          at ManagedPromise.invokeCallback_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1376:14)
          at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3084:14)
          at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3067:27)
          at asyncRun (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2927:27)
          at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:668:7
          at process._tickCallback (internal/process/next_tick.js:109:7)
      From: Task: <anonymous wait>
          at scheduleWait (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2188:20)
          at ControlFlow.wait (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2517:12)
          at thenableWebDriverProxy.wait (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:934:29)
          at run (/usr/lib/node_modules/protractor/built/browser.js:59:33)
          at ProtractorBrowser.to.(anonymous function) [as wait] (/usr/lib/node_modules/protractor/built/browser.js:67:16)
          at Object.logOut (/var/lib/jenkins/workspace/QA-develop-UI-E2E-Tests-General/lyncs/e2e-tests/helpers/navigation.js:67:17)
          at UserContext.<anonymous> (/var/lib/jenkins/workspace/QA-develop-UI-E2E-Tests-General/lyncs/e2e-tests/specs/general/changeExpiredPassword.spec.js:271:41)
          at /usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:112:25
          at new ManagedPromise (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1077:7)
          at ControlFlow.promise (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2505:12)
      From: Task: Run afterAll in control flow
          at UserContext.<anonymous> (/usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:94:19)
          at runCallback (timers.js:672:20)
          at tryOnImmediate (timers.js:645:5)
      From asynchronous test: 
      Error
          at Suite.<anonymous> (/var/lib/jenkins/workspace/QA-develop-UI-E2E-Tests-General/lyncs/e2e-tests/specs/general/changeExpiredPassword.spec.js:270:9)
          at Object.<anonymous> (/var/lib/jenkins/workspace/QA-develop-UI-E2E-Tests-General/lyncs/e2e-tests/specs/general/changeExpiredPassword.spec.js:24:1)
          at Module._compile (module.js:571:32)
          at Object.Module._extensions..js (module.js:580:10)
          at Module.load (module.js:488:32)
          at tryModuleLoad (module.js:447:12)

The error refers to the line:

browser.wait(EC.visibilityOf(element(by.id("loggedInUser"))), 50000);
  • Steps to reproduce the bug
  • The URL you are running your tests against (if relevant)
    The URL is not publicly available but I've listed below the relevant code:
<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
	<ul class="nav navbar-nav navbar-right">
		<li class="dropdown open">
			<a aria-expanded="true" class="dropdown-toggle ng-binding" data-toggle="dropdown" id="loggedInUser"><i class="glyphicon glyphicon-user text-info"></i> someUser<b class="caret"></b></a>
			<ul class="dropdown-menu">
				<li class="">
					<a href="#/user/changePassword" id="changePasswordLink">Change Password</a>
				</li>
				<li class="divider"></li>
				<li class="">
					<a id="logOutLink">Sign out</a>
				</li>
			</ul>
		</li>
	</ul>
</body>
</html>

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions