PixnBits/karma-selenium-webdriver-launcher

Errors during setup (maybe a version problem)

Closed this issue · 9 comments

Hi,
I'm trying to setup a test-environment using karma/selenium and your plugin.
My current setup includes

Packages

    "karma": "~0.12.31",
    "selenium-webdriver": "~2.45.1",
    "karma-selenium-webdriver-launcher": "0.0.1"

karma.conf.js

var By = require('selenium-webdriver').By,
    until = require('selenium-webdriver').until,
    firefox = require('selenium-webdriver/firefox'),
    webdriver = require('selenium-webdriver')
    ;

module.exports = function(config){
    config.set({

        basePath : '../',

        files : [
            'web/bower_components/angular/angular.js',
            'web/bower_components/angular-cookies/angular-cookies.js',
            'web/bower_components/angular-mocks/angular-mocks.js',
            'web/js/MyStuff/**/*.js'
        ],

        autoWatch : true,

        frameworks: ['jasmine'],

        // define browsers
        customLaunchers: {
            swd_firefox: {
                base: 'SeleniumWebdriver',
                browserName: 'firefox',
                getDriver: function(){
                    // example from https://www.npmjs.com/package/selenium-webdriver#usage
                    var driver = new webdriver.Builder()
                        .forBrowser('firefox')
                        .usingServer('http://127.0.0.1:4444/wd/hub')
                        .build();

                    //   var driver = new firefox.Driver(); the above solution works headless
                    return driver;
                }
            }
        },

        browsers : ['swd_firefox'],

        plugins : [
            'karma-selenium-webdriver-launcher',
            'karma-jasmine'
        ],
    });
};

With this configuration I experience multiple problems.

  • When starting the tests via. the --single-run option the session is not killed after it ended all I get is INFO [launcher.selenium-webdriver]: requested to kill, session id is 220f239a-fa10-4edc-80a8-89e87d857faf over and over again
  • When starting the tests without the single-run option I'm getting:
ERROR [karma]: [TypeError: Object firefox 35.0.1 (LINUX) via Selenium Webdriver has no method 'isCaptured']
TypeError: Object firefox 35.0.1 (LINUX) via Selenium Webdriver has no method 'isCaptured'
    at /home/dev/node_modules/karma/lib/launcher.js:149:23
    at Array.some (native)
    at areAllCaptured (/home/dev/node_modules/karma/lib/launcher.js:148:22)
    at null.<anonymous> (/home/dev/node_modules/karma/lib/server.js:85:38)
    at EventEmitter.emit (events.js:95:17)
    at init (/home/dev/node_modules/karma/lib/browser.js:81:13)
    at Socket.<anonymous> (/home/dev/node_modules/karma/lib/server.js:123:20)
    at Socket.EventEmitter.emit [as $emit] (events.js:95:17)
    at SocketNamespace.handlePacket (/home/dev/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22)
    at Manager.onClientMessage (/home/dev/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38)

Which can be fixed by adding a isCaptured method which returns true to your plugin but I assume this is not the fix that should be applied.

If you need any further details please let me know. I'm relatively knew to karma / selenium so maybe I'm missing something.

cheers
christoph

TBH I hadn't tried a single run, so the isCaptured method may be more important that I thought :P
I'll look at https://github.com/karma-runner/karma/blob/51f1b8832b86c4f556b58381fa183776212cfaa7/lib/launchers/base.js to see what's expected by karma

Just to be ask, you've tried karma-firefox-launcher but need more control?

No I havent tried that yet,
I need the selenium version for our build-system.

We have behat-tests that run using a headless version of the selenium-server so I figured running our karma tests via. the same browser-driver will make things easier :)

I think I found it. Turns out .kill(...) should take a callback. I really wish this was documented somewhere other than just code. :P

Sorry about that, github has auto-close per commit message logic.
Please test in your setup to confirm that this change resolves the issue. (Tested on my box, confirm on yours, too)
If so, I'll release a new version. (So you might need to check out this repo (or just edit index.js) to test)

Hi thanks for the patch, the termination problem seems to be fixed now but I'm still getting the error:
[TypeError: Object firefox 36.0 (LINUX) via Selenium Webdriver has no method 'isCaptured']

ERROR [karma]: [TypeError: Object firefox 36.0 (LINUX) via Selenium Webdriver has no method 'isCaptured']
TypeError: Object firefox 36.0 (LINUX) via Selenium Webdriver has no method 'isCaptured'
    at /home/dev/node_modules/karma/lib/launcher.js:149:23
    at Array.some (native)
    at areAllCaptured (/home/dev/node_modules/karma/lib/launcher.js:148:22)
    at null.<anonymous> (/home/dev/node_modules/karma/lib/server.js:85:38)
    at EventEmitter.emit (events.js:95:17)
    at init (/home/dev/node_modules/karma/lib/browser.js:81:13)
    at Socket.<anonymous> (/home/dev/node_modules/karma/lib/server.js:123:20)
    at Socket.EventEmitter.emit [as $emit] (events.js:95:17)
    at SocketNamespace.handlePacket (/home/dev/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22)
    at Manager.onClientMessage (/home/dev/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38)

whoops, try it now

Great it's fully working now thanks for your efforts. 👍

Thanks for testing on your end!