Cannot run protractor on Internet explorer 11

2020-03-29 04:41发布

问题:

I'm trying to run my jasmine E2E tests on IE11 but with no luck or whatsoever. I'm on Windows 8.1. My config:

exports.config = {
    directConnect: true,

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    },

    // run in multiple browsers
    multiCapabilities:[
     //    {
     //        'browserName': 'chrome'
     //    },
        // {
     //        'browserName': 'firefox'
     //    },       
        {
           'browserName': 'internet explorer',
        }
    ],

    // Spec patterns are relative to the current working directly when
    // protractor is called.
    specs: ['./**/*js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    },

    onPrepare: function () {
        // The require statement must be down here, since jasmine-reporters@1.0
        // needs jasmine to be in the global and protractor does not guarantee
        // this until inside the onPrepare function.
        require('jasmine-reporters');
        jasmine.getEnv().addReporter(
            new jasmine.JUnitXmlReporter('xmloutput', true, true)
        );
    }
};

Chrome and Firefox work like a charm but IE gives me this:

Error: browserName (internet explorer) is not supported with directConnect.

IEDriverServer.exe is added to my path. I've did all the requred config: https://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_Configuration

Any ideas?

回答1:

According to Connecting Directly to Browser Drivers directConnect setting would work for Firefox and Chrome only:

directConnect: true - Your test script communicates directly Chrome Driver or Firefox Driver, bypassing any Selenium Server. If this is true, settings for seleniumAddress and seleniumServerJar will be ignored. If you attempt to use a browser other than Chrome or Firefox an error will be thrown.

You need to remove/comment out directConnect:

exports.config = {
    multiCapabilities:[
        {
           'browserName': 'internet explorer'
        }
    ],
    ...
}

FYI, you can actually leave capabilities defined alongside with multiCapabilities, but in this case protractor would simply ignore capabilities and use multiCapabilities (docs).



回答2:

Your config file like this below

exports.config = { multiCapabilities: { 'browserName': 'internet explorer',
}, framework: 'jasmine', specs: ['example_spec.js'], jasmineNodeOpts: { defaultTimeoutInterval: 30000 } };



回答3:

Direct connect supports Chrome and Firefox browsers. It doesn't do the same for Internet Explorer, though.