alecxe alecxe - 2 years ago 194
Javascript Question

multiCapabilities and jasmine focused tests

The Story:

We have a rather huge end-to-end protractor test codebase. We have two configs - one is "local" - to run the tests in Chrome and Firefox using

, and the other one is "remote" - to run tests on a remote selenium server - BrowserStack in our case.

Our "local" config is configured to run some tests in Chrome and some in Firefox - because we really cannot run some tests in Chrome - for instance, keyboard shortcuts don't work in Chrome+Mac. Running the tests that require using keyboard shortcuts in Firefox is a workaround until the linked
issue is resolved.

Here is the relevant part of the configuration:

var firefox_only_specs = [

exports.config = {
directConnect: true,

multiCapabilities: [
browserName: "chrome",
chromeOptions: {
args: ["incognito", "disable-extensions", "start-maximized"]
specs: [
exclude: firefox_only_specs
browserName: "firefox",
specs: firefox_only_specs

// ...

The problem:

Now, the problem is that, if I'm debugging a single test, or want to run a single test - I'm marking it is as focused (via
) - but protractor starts two driver sessions - one for Chrome and the other one for Firefox, using both configured capabilities:

Running "protractor:local" (protractor) task
[launcher] Running 2 instances of WebDriver

[chrome #1] PID: 2329
[chrome #1] Using ChromeDriver directly...
[chrome #1] Spec started


[firefox #2] PID: 2330
[firefox #2] Using FirefoxDriver directly...
[firefox #2] Spec started


The question:

Is there a way to tell protractor to use the only one capability that has a focused spec configured?

Using currently latest

Hope the question is clear. Let me know if you need any additional information.

Answer Source

I wonder if you can do something to wrap the it statements like:

onPrepare: function() {
    browser.getCapabilities().then(function(caps) {
        global.browserName = caps.caps_.browserName;

    global.firefoxOnly = function(name, testFunction) {
        if (browserName === 'firefox') {
            return it(name, testFunction);
        } else {
            return xit(name, testFunction).pend('firefox only');

Then when you write a test, instead of it use something like:

describe('when I do something', function() {
    firefoxOnly('it should do the right thing', function() {

I have no idea if this actually works, just throwing it out there. In fact, when I get back to my testing computer and try it out, I would be interested in adding a function like wip to use instead of xit to automatically pend my ATDD tests!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download