Created
February 23, 2016 17:00
-
-
Save klamping/a1e2f670edc2a5aef338 to your computer and use it in GitHub Desktop.
wdio -> browserstack session info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Resets the browser for the next set of tests and sets the test name | |
| * for Browserstack organization | |
| * | |
| * @param {object} mochaTest The Mocha 'test' object (should be `this` in your tests) | |
| * @param {object} [viewportSize] | |
| * @param {number} [viewportSize.width] - Viewport width; defaults to 1280 | |
| * @param {number} [viewportSize.height] - Viewport height, defaults to 960 | |
| * @example | |
| * browser.startNewSession(this); | |
| * @example | |
| * browser.startNewSession(this, { width: 1000, height: 1000 }); | |
| */ | |
| browser.addCommand("startNewSession", function(mochaTest, viewportSize) { | |
| if (!viewportSize) { | |
| viewportSize = { width: 1280, height: 960 }; | |
| } | |
| var capabilities = {}; | |
| if (mochaTest) { | |
| var test = mochaTest.currentTest || mochaTest.test; | |
| capabilities.name = test.fullTitle(); | |
| } | |
| return browser | |
| .end() | |
| .init(capabilities) | |
| .setViewportSize(viewportSize) | |
| ; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("main navigation #smoke", function() { | |
| beforeEach(function() { | |
| return browser | |
| .startNewSession(this) | |
| .url("/"); | |
| }); | |
| it("should correctly navigate to a page", function() { | |
| return browser | |
| .doSomething(); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var _ = require("lodash"); | |
| var getRequestedBrowsers = require("./getRequestedBrowsers.js"); | |
| var config = require("./config.js"); | |
| capabilities = getRequestedBrowsers(config.browsers); | |
| // set up browserstack "project" and "build" settings for better test organization | |
| var extraCapabilities = { | |
| project: process.env.npm_package_name | |
| }; | |
| if (process.env.BUILD_NUMBER) { | |
| extraCapabilities.build = "Jenkins #" + process.env.BUILD_NUMBER; | |
| } else { | |
| extraCapabilities.build = config.user + " " + timestamp(); | |
| } | |
| capabilities = _.map(capabilities, function(browserCapabilities) { | |
| return _.merge(browserCapabilities, extraCapabilities); | |
| }); | |
| ## lots more config stuff here |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example browserstack output:
