easy-sauce icon indicating copy to clipboard operation
easy-sauce copied to clipboard

Use flexible syntax to specify browsers

Open lpinca opened this issue 9 years ago • 5 comments

Would you be interested in adding a more flexible syntax to specify the platforms/browsers/versions? For example:

{
  "platforms": [
    {
      "name": "internet explorer",
      "version": "oldest..latest"
    },
    {
      "name": "chrome",
      "version": ["oldest", "latest"]
    }
  ]
}

What I'm thinking is the same syntax used in zuul. The advantage is that you don't have to update the config if a new version of a browser is added in SauceLabs. The same applies for removed versions.

Converting this syntax to the required format is easy (the code can be extracted from zuul) and can be done in a separate npm module.

The only problem I see is that it isn't backward compatible.

Thoughts?

lpinca avatar Apr 07 '17 16:04 lpinca

Sure, that would be cool. Out of curiosity, why do you say it wouldn't be backwards compatible? Presumably if it didn't find a .., it would just assume a single version, no?

Also, I assume this technique would need to query the Sauce Labs API to see what versions/platforms are available. Is that what zuul does?

philipwalton avatar Apr 07 '17 18:04 philipwalton

Well currently you have an array of arrays. The new config will be an array of objects. Maybe we can check if the first element is an array and determine how to handle the config based on this info.

Yes zuul get all browsers from https://saucelabs.com/rest/v1/info/browsers/webdriver, see https://github.com/defunctzombie/zuul/blob/8f8adf0ae0c4ebf196a65b92173dfcacd0c7a64b/lib/scout_browser.js.

lpinca avatar Apr 07 '17 18:04 lpinca

I published sauce-browsers. It works like this:

const browsers = [
  { name: 'firefox', version: 50, platform: 'Mac 10.9'},
  { name: 'chrome', version: ['oldest', 'latest'] },
  { name: 'safari', version: 'oldest..latest' }
];

sauceBrowsers(browsers).then((platforms) => {
  platforms = browsers.map((el) => [el.os, el.api_name, el.short_version]);
  // `platforms` can now be used in `easy-sauce`.
}).catch((err) => console.error(err.stack));

lpinca avatar Apr 10 '17 20:04 lpinca

Support for https://github.com/ai/browserslist would be great. Tools such as https://github.com/babel/babel-preset-env use it.

rtsao avatar Apr 11 '17 17:04 rtsao

@rtsao yeah I thought that but afaik there is no way to specify the OS in browserlist and it doesn't query Sauce Labs to actually know what browsers are available.

lpinca avatar Apr 11 '17 17:04 lpinca