webdriverio-boneyard / gulp-webdriver

gulp-webdriver is a gulp plugin to run selenium tests with the WebdriverIO testrunner
http://webdriver.io
MIT License
76 stars 33 forks source link

Selenium never stops #59

Closed akougblenou closed 7 years ago

akougblenou commented 7 years ago

I was trying to setup my integration tests and I keep getting this error :

wdio.conf.js

exports.config = {
    specs: [
        'src/**/*.int.js'
    ],
    // Patterns to exclude.
    exclude: [
        // 'path/to/excluded/files'
    ],

    maxInstances: 10,

    capabilities: [{
        maxInstances: 5,
        browserName: 'firefox'
    }],
    sync: true,
    logLevel: 'error',
    coloredLogs: true,
    bail: 0,
    screenshotPath: './errorShots/',
    baseUrl: 'http://localhost:8099/Authentication.php',
    waitforTimeout: 120000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 10,
    services: ['selenium-standalone','phantomjs'],
    framework: 'mocha',
    mochaOpts: {
        ui: 'bdd'
    },
}

gulpfile.js

import yargs from 'yargs';
import gulp from 'gulp';
import del from 'del';
import {Server} from 'karma';
import webdriver from 'gulp-webdriver';
import selenium from 'selenium-standalone'
import restructureTree from './plugins/gulp-restructure-tree';
import { paths, pathMoveRules } from './config';

/* =Command-line arguments and config
 *------------------------------------------------------------*/

// some unrelated commands

/* =Tasks
 *------------------------------------------------------------*/

// other tasks goes here
export function wd_test() {
    return gulp.src('wdio.conf.js').pipe(webdriver({
        logLevel: 'verbose',
        waitforTimeout: 120000,
        reporter: 'spec'
    }));
}

export const build_app = gulp.series(clean, gulp.parallel(styles_app, scripts_app, others_app));
export const build = build_app;

export default build;

test.int.js

var chai              = require('chai');
var expect            = chai.expect;
var assert            = chai.assert;
var should            = chai.should();

describe('my awesome website', function() {
    it('should do some chai assertions', function() {
        browser.url('/');
        browser.getTitle().should.be.equal('Authentification');
    });
    after(function(){
        browser.end();
    })
});

Also not sure how but when I use before(), beforeEach(), after() and afterEach() in the test I either get the test failing or I get "after all", "after each" hook failing.

I also get an error in the test from time to time about the timeout (exceeded 10000ms) whereas the timeout limit was set to 120000ms.

Any help appreciated.

christian-bromann commented 7 years ago

ok:

  1. don't call browser.end(); when using the wdio testrunner, it's the job of the testrunner to take care of booting and ending selenium sessions
  2. Another Selenium process may already be running - you have selenium standalone and phantomjs as a service defined - you only need selenium-standalone here because it will start a phantomjs server for you
akougblenou commented 7 years ago

OK well I have found the real issue:

  1. That was a desperate attempt to get something to work (but obviously it was silly)
  2. I will remove PhantomJS thank you
  3. (2bis actually) the real issue came from the Java version of my machine, it makes selenium difficult to impossible to start or be killed. And the particular issue while on Mac OS X is that while you may download a new version of Java you need to create a new symlink to the downloaded version as it does not override the Mac OS native version, more on that here: https://gist.github.com/johan/1059046

Posting it here for anybody who may experience the same issue.