diff --git a/docs/mobile-setup.md b/docs/mobile-setup.md index c18d36181..68e89e17f 100644 --- a/docs/mobile-setup.md +++ b/docs/mobile-setup.md @@ -29,11 +29,6 @@ page](https://github.com/angular/webdriver-manager/blob/master/docs/mobile.md)). * Configure protractor: -additional dependencies: -```shell -npm install --save-dev wd wd-bridge -``` - Config File: ```javascript exports.config = { @@ -49,17 +44,7 @@ exports.config = { deviceName: 'Android Emulator', }, - baseUrl: 'http://10.0.2.2:8000', - - // configuring wd in onPrepare - // wdBridge helps to bridge wd driver with other selenium clients - // See https://github.com/sebv/wd-bridge/blob/master/README.md - onPrepare: function () { - var wd = require('wd'), - protractor = require('protractor'), - wdBridge = require('wd-bridge')(protractor, wd); - wdBridge.initFromProtractor(exports.config); - } + baseUrl: 'http://10.0.2.2:8000' }; ``` *Note the following:* @@ -91,11 +76,6 @@ Starting express web server in /workspace/protractor/testapp on port 8000 * Configure protractor: -additional dependencies: -```shell -npm install --save-dev wd wd-bridge -``` - iPhone: ```javascript exports.config = { @@ -113,17 +93,7 @@ exports.config = { deviceName: 'iPhone Simulator', }, - baseUrl: 'http://localhost:8000', - - // configuring wd in onPrepare - // wdBridge helps to bridge wd driver with other selenium clients - // See https://github.com/sebv/wd-bridge/blob/master/README.md - onPrepare: function () { - var wd = require('wd'), - protractor = require('protractor'), - wdBridge = require('wd-bridge')(protractor, wd); - wdBridge.initFromProtractor(exports.config); - } + baseUrl: 'http://localhost:8000' }; ``` @@ -144,17 +114,7 @@ exports.config = { deviceName: 'IPad Simulator', }, - baseUrl: 'http://localhost:8000', - - // configuring wd in onPrepare - // wdBridge helps to bridge wd driver with other selenium clients - // See https://github.com/sebv/wd-bridge/blob/master/README.md - onPrepare: function () { - var wd = require('wd'), - protractor = require('protractor'), - wdBridge = require('wd-bridge')(protractor, wd); - wdBridge.initFromProtractor(exports.config); - } + baseUrl: 'http://localhost:8000' }; ``` @@ -231,3 +191,30 @@ exports.config = { *Note the following:* - browserName is 'android' - baseUrl is 10.0.2.2 instead of localhost because it is used to access the localhost of the host machine in the android emulator + +Using `wd` and `wd-bridge` +------------------------------------- + +As of version 5.1.0, Protractor uses `webdriver-js-extender` to provide all the +mobile commands you should need (see the API page for details). However, if you +prefer `wd`, you can access it via `wd-bridge`. First, install both `wd` and +`wd-bridge` as `devDependencies`: + +```shell +npm install --save-dev wd wd-bridge +``` + +Then, in your config file: + +```javascript + // configuring wd in onPrepare + // wdBridge helps to bridge wd driver with other selenium clients + // See https://github.com/sebv/wd-bridge/blob/master/README.md + onPrepare: function () { + var wd = require('wd'), + protractor = require('protractor'), + wdBridge = require('wd-bridge')(protractor, wd); + wdBridge.initFromProtractor(exports.config); + } +``` + diff --git a/lib/frameworks/jasmine.js b/lib/frameworks/jasmine.js index 0ecd95f9c..89d4b4ef1 100644 --- a/lib/frameworks/jasmine.js +++ b/lib/frameworks/jasmine.js @@ -63,7 +63,7 @@ exports.run = function(runner, specs) { var jrunner = new JasmineRunner(); /* global jasmine */ - require('jasminewd2').init(webdriver.promise.controlFlow()); + require('jasminewd2').init(webdriver.promise.controlFlow(), webdriver); var jasmineNodeOpts = runner.getConfig().jasmineNodeOpts; diff --git a/lib/webdriver-js-extender/index.js b/lib/webdriver-js-extender/index.js index 9e836ec54..2c424f137 100644 --- a/lib/webdriver-js-extender/index.js +++ b/lib/webdriver-js-extender/index.js @@ -35,35 +35,13 @@ goog.provide('webdriver_extensions'); webdriver_extensions.ExtendedWebDriver = function() {}; /** - * Schedules a command to retrieve the network connection type. + * Various appium commands, including the commands implemented by `wd`. The + * names may be different however, and commands which are implemented already by + * `selenium-webdriver` are not re-implemented by `webdriver-js-extender`. * - * Network connection types are a bitmask with: - * 1 -> airplane mode - * 2 -> wifi - * 4 -> data + * See the [GitHub repo](https://github.com/angular/webdriver-js-extender) for + * details. * - * @example - * expect(browser.getNetworkConnection()).toBe(6); //Expect wifi and data on - * - * @returns {!webdriver.promise.Promise.} A promise that will be - * resolved with the current network connection type. - */ -webdriver_extensions.ExtendedWebDriver.prototype.getNetworkConnection = function() {}; - -/** - * Schedules a command to set the network connection type. - * - * Network connection types are a bitmask with: - * 1 -> airplane mode - * 2 -> wifi - * 4 -> data - * - * @example - * browser.setNetworkConnection(1); //Turn on airplane mode - * expect(browser.getNetworkConnection()).toBe(1); - * - * @param {number} type The type to set the network connection to. - * @returns {!webdriver.promise.Promise.} A promise that will be - * resolved when the network connection type is set. + * @returns {!webdriver.promise.Promise.<*>} */ -webdriver_extensions.ExtendedWebDriver.prototype.setNetworkConnection = function(type) {}; +webdriver_extensions.ExtendedWebDriver.prototype.Appium_Commands = function() {}; diff --git a/package.json b/package.json index 3aad3ca5b..7ef0226a7 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,14 @@ "chalk": "^1.1.3", "glob": "^7.0.3", "jasmine": "2.4.1", - "jasminewd2": "~0.1.0", + "jasminewd2": "^2.0.0", "optimist": "~0.6.0", "q": "1.4.1", "saucelabs": "~1.3.0", "selenium-webdriver": "3.0.1", "source-map-support": "~0.4.0", "webdriver-manager": "^11.1.1", - "webdriver-js-extender": "^0.2.2" + "webdriver-js-extender": "^1.0.0" }, "devDependencies": { "@types/chalk": "^0.4.28",