I ran into a problem while running my e2e tests on a selenium grid. Sometimes tests fail because of
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
I tried to somehow solve this problem by changing defaultTimeoutInterval to a higher value in protracotr.conf.js , but as a result, the wait is longer, but the error is the same.
exports.config = { chromeOnly: true, chromeDriver: '../node_modules/.bin/chromedriver', framework: 'jasmine2', capabilities: { 'browserName': 'chrome', shardTestFiles: true, maxInstances: 3 }, specs: ['../e2e/protractor/spec/*.js'], jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000, isVerbose: true, includeStackTrace: true, },
My sample specification with a failed test:
var LoginPage = require('../pages/login_page.js'); var UsersPage = require('../pages/users_page.js'); var WelcomePage = require('../pages/welcome_page.js'); describe('Test -> my test', function () { var loginPage; var EC = protractor.ExpectedConditions; var waitTimeout = 30000; function logIn() { loginPage.setUser('user'); loginPage.setPassword('password'); loginPage.login(); } var clickOn = function (element) { browser.wait(EC.visibilityOf(element), waitTimeout).then(function () { element.click(); }); }; beforeEach(function () { browser.ignoreSynchronization = true; loginPage = new LoginPage(); browser.wait(EC.presenceOf(loginPage.userLogin), waitTimeout); logIn(); var welcomePage = new WelcomePage; clickOn(welcomePage.usersButton); }); afterEach(function () { var welcomePage = new WelcomePage(); welcomePage.loginButton.click(); welcomePage.logoutButton.click(); }); it('verifies counter on active tab', function () { var usersPage = new UsersPage(); browser.wait(EC.visibilityOf(usersPage.firstRow), waitTimeout); usersPage.rowsCount.count().then(function (count) { expect(usersPage.activeTab.getText()).toContain('Active' + ' (' + count + ')'); }); });
Can anyone suggest any reasonable solution on how to handle this / avoid it and explain why this is happening?
source share