Skip to content

Instantly share code, notes, and snippets.

@jrgm
Last active December 14, 2015 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrgm/5075399 to your computer and use it in GitHub Desktop.
Save jrgm/5075399 to your computer and use it in GitHub Desktop.
A test hack that just dumps some info about what userAgent we get on Saucelabs for various {version,browserName,platform}. For checking config changes in mozilla/browserid/automation-tests/config/sauce-platforms.js
#!/usr/bin/env node
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This test is only intended for occasional use to confirm the actual browser
// userAgent and OS. Useful in checking changes to sauce-platforms.js.
const
assert = require('../lib/asserts.js'),
utils = require('../lib/utils.js'),
runner = require('../lib/runner.js'),
persona_urls = require('../lib/urls.js'),
fs = require('fs'),
path = require('path');
var testSetup = require('../lib/test-setup.js');
var browser;
var logFile = '/tmp/useragent.txt'; // XXX win32?
var getUserAgent = "(function() { return navigator.userAgent })()";
runner.run(module, {
"create a new selenium session": function(done) {
testSetup.setup({b:1}, function(err, fix) {
if (fix) {
browser = fix.b[0];
}
done(err);
});
},
"start the session": function(done) {
testSetup.newBrowserSession(browser, done);
},
"open the frontend test url": function(done) {
browser.get(persona_urls['persona'], done);
},
"grab and log the userAgent string": function(done) {
browser.eval(getUserAgent, function(err, ua) {
if (ua && typeof ua === 'string') {
var res = { ua: ua };
var sessionOpts = testSetup.sessionOpts;
res.version = sessionOpts.version || 'unknown';
res.browserName = sessionOpts.browserName || 'unknown';
res.platform = sessionOpts.platform || 'unknown';
fs.appendFileSync(logFile, JSON.stringify(res) + '\n');
}
done(err);
});
},
"shut down": function(done) {
browser.quit(done);
}
},
{
suiteName: path.basename(__filename),
cleanup: function(done) { testSetup.teardown(done) }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment