thefrontside / bigtest

Ensure your React/Vue/Ember/anything app works perfectly across browsers.
https://frontside.com/bigtest
99 stars 14 forks source link

Pass through arbitrary options to drivers #857

Open jnicklas opened 3 years ago

jnicklas commented 3 years ago

Currently when defining a driver, we can define it like this:

"chrome.headless": {
  module: "@bigtest/webdriver",
  options: {
    type: 'local',
    browserName: "chrome",
    headless: true
  }
},

There are no other options aside from these. However, the various browsers can be started with a whole bunch of options. For example I wanted to create a chrome.debug driver, with --auto-open-devtools-for-tabs. This is currently not possible, since there is no way to pass through this option. One option would be to change this to something like:

"chrome.headless": {
  module: "@bigtest/webdriver",
  options: {
    type: 'local',
    browserName: "chrome",
    capabilities: {
       "goog:chromeOptions": {
         args: ["headless"]
       }
    }
  }
},

This is much more explicit, and makes it clearer how to configure other capabilities, but it does make it harder to set up new drivers.

Also, the browserName bit is slightly confusing, since it isn't really configuring what browser to use, but rather which executable to run, chromedriver, geckodriver, etc... So maybe it would make sense to change this? But what would a better name be?

I don't think that there are any custom driver setups in the wild yet, so at this point in time this should still be fairly easy to change.

cowboyd commented 3 years ago

WRT the capabilities argument, this seems very reasonable.

For the case of the "browser name", one of the things that has always bothered me is that the browserName means nothing if the if the type is "remote". By the same token, if the type is remote, then where does the url come from?

Perhaps, the local/remote options should be under the local/remote key.

{
"chrome.headless": {
  module: "@bigtest/webdriver",
  options: {
    local: 'chromdriver',
    capabilities: {
       "goog:chromeOptions": {
         args: ["headless"]
       }
    }
  }
},
"safari": {
  module: "@bigtest/webdriver",
  options: {
    remote: "https://api.saucelabs.com",
    capabilities: {
      "safari:webkitOptions" {
        "args": []
      }
    }
  }
}
}
jnicklas commented 3 years ago

That's a much improved API, IMO. It might be worth questioning even the local/remote dichotomy. It seems like this is something that is somewhat ingrained in webdriver, but an even more descriptive alternative might be something like this:

{
"chrome.headless": {
  module: "@bigtest/webdriver",
  options: {
    binary: 'chromedriver',
    capabilities: {
       "goog:chromeOptions": {
         args: ["headless"]
       }
    }
  }
},
"safari": {
  module: "@bigtest/webdriver",
  options: {
    url: "https://api.saucelabs.com",
    capabilities: {
      "safari:webkitOptions" {
        "args": []
      }
    }
  }
}
}
cowboyd commented 3 years ago

That looks perfect 👌🏼