Repository: nightwatchjs/nightwatch
Pull request #2764 (2021-06-28 11:58:40)

refactor transport testcases
### Changes
- refactor test cases to work with selenium-webdriver.
- refactor `/transport/factory.js` to support `didyoumean` in case of wrong browsername

### Needs Work
- need to refactor test cases in transport for browserstack.


Patch:
diff --git a/lib/api/_loaders/command.js b/lib/api/_loaders/command.js
index 0b9aded8..19ef8d29 100644
--- a/lib/api/_loaders/command.js
+++ b/lib/api/_loaders/command.js
@@ -104,6 +104,10 @@ class CommandLoader extends BaseCommandLoader {
         return this.client.transportActions;
       }
 
+      get driver() {
+        return this.client.transport.driver;
+      }
+
       httpRequest(requestOptions) {
         return this.client.transport.runProtocolAction(requestOptions);
       }
@@ -149,6 +153,11 @@ class CommandLoader extends BaseCommandLoader {
           commandName: this.commandName
         });
 
+        if (instance.w3c_deprecated) {
+          let extraMessage = instance.deprecationNotice ? `\n  ${instance.deprecationNotice}` : '';
+          console.warn(`This command has been deprecated and is removed from the W3C Webdriver standard. It is only working with legacy Selenium JSONWire protocol.${extraMessage}`);
+        }
+
         const result = this.resolveElementSelector(args)
           .then(elementResult => {
             if (elementResult) {
diff --git a/lib/api/element-commands/_baseElementCommand.js b/lib/api/element-commands/_baseElementCommand.js
index 66fd6481..635f4c09 100644
--- a/lib/api/element-commands/_baseElementCommand.js
+++ b/lib/api/element-commands/_baseElementCommand.js
@@ -3,12 +3,43 @@ const Utils = require('../../utils');
 const {Logger, filterStackTrace} = Utils;
 
 class BaseElementCommand extends ElementCommand {
+  get w3c_deprecated() {
+    return false;
+  }
+
+  static get RetryableElementErrors() {
+    return [
+      'ElementNotInteractableError',
+      'ElementClickInterceptedError',
+      'ElementNotSelectableError',
+      'ElementNotVisibleError',
+      'InvalidElementStateError',
+      'JavascriptError'
+    ];
+  }
+
+  static getErrorMessage(response = {}) {
+    const {value, error = ''} = response;
+
+    if (value && value.error) {
+      return value.error;
+    }
+
+    return error;
+  }
+
+  static isRetryableElementError(error) {
+    return BaseElementCommand.RetryableElementErrors.includes(error.name);
+  }
+
   get extraArgsCount() {
     return 0;
   }
 
   get retryOnFailure() {
-    return this.__retryOnFailure || false;
+    return () => {
+      return this.__retryOnFailure || false;
+    };
   }
 
   get elementProtocolAction() {
@@ -30,6 +61,9 @@ class BaseElementCommand extends ElementCommand {
     const validate = (result) => this.isResultSuccess(result);
     const successHandler = (result) => this.complete(null, result);
 
+    this.elementCommandRetries = 0;
+    this.maxElementCommandRetries = this.settings.element_command_retries;
+
     this.executor
       .queueAction({
         action: () => this.findElementAction(),
@@ -54,7 +88,7 @@ class BaseElementCommand extends ElementCommand {
       .queueAction({
         action: (response) => this.elementFound(response),
         retryOnSuccess: this.retryOnValidActionResult,
-        retryOnFailure: this.retryOnFailure,
+        retryOnFailure: this.retryOnFailure.bind(this),
         validate: (result) => this.transport.isResultSuccess(result),
         isResultStale,
         successHandler,
@@ -66,19 +100,36 @@ class BaseElementCommand extends ElementCommand {
     return this.handleElementError(err);
   }
 
-  protocolAction() {
+  shouldRetryElementCommand(result) {
+    if ((result.error instanceof Error) && BaseElementCommand.isRetryableElementError(result.error) && this.elementCommandRetries < this.maxElementCommandRetries) {
+      return true;
+    }
+
+    return false;
+  }
+
+  async protocolAction() {
     if (!this.elementProtocolAction) {
       throw new Error('Define elementProtocolAction.');
     }
 
-    return this.executeProtocolAction(this.elementProtocolAction, this.args);
+    const result = await this.executeProtocolAction(this.elementProtocolAction, this.args);
+
+    if (this.shouldRetryElementCommand(result)) {
+      this.__retryOnFailure = true;
+      this.elementCommandRetries++;
+    } else {
+      this.__retryOnFailure = false;
+    }
+
+    return result;
   }
 
   handleElementError(err) {
     const shouldRegister = this.transport.shouldRegisterError(err);
-    const errorMessage = err.response && err.response.value && err.response.value.error ? (err.response.value.error + '; ' + err.response.value.message) : '';
+    let originalErrorMessage = BaseElementCommand.getErrorMessage(err.response);
 
-    err.message = `An error occurred while running .${this.commandName}() command on <${this.element.toString()}>: ${errorMessage}`;
+    err.message = `An error occurred while running .${this.commandName}() command on <${this.element.toString()}>: ${originalErrorMessage}`;
     err.detailedErr = JSON.stringify(err.response);
     err.stack = filterStackTrace(this.stackTrace);
 
diff --git a/lib/api/element-commands/getElementRect.js b/lib/api/element-commands/getElementRect.js
index 7e68e79d..9447f8f9 100644
--- a/lib/api/element-commands/getElementRect.js
+++ b/lib/api/element-commands/getElementRect.js
@@ -52,7 +52,7 @@ class GetElementSize extends BaseElementCommand {
   }
 
   get elementProtocolAction() {
-    return 'getElementSize';
+    return 'getElementRect';
   }
 }
 
diff --git a/lib/api/element-commands/getElementSize.js b/lib/api/element-commands/getElementSize.js
index 7e68e79d..9447f8f9 100644
--- a/lib/api/element-commands/getElementSize.js
+++ b/lib/api/element-commands/getElementSize.js
@@ -52,7 +52,7 @@ class GetElementSize extends BaseElementCommand {
   }
 
   get elementProtocolAction() {
-    return 'getElementSize';
+    return 'getElementRect';
   }
 }
 
diff --git a/lib/api/element-commands/getLocation.js b/lib/api/element-commands/getLocation.js
index e55f99f6..f9d2127f 100644
--- a/lib/api/element-commands/getLocation.js
+++ b/lib/api/element-commands/getLocation.js
@@ -54,7 +54,7 @@ class GetLocation extends BaseElementCommand {
   }
 
   get elementProtocolAction() {
-    return 'getElementLocation';
+    return 'getElementRect';
   }
 }
 
diff --git a/lib/api/element-commands/getLocationInView.js b/lib/api/element-commands/getLocationInView.js
index 2d1acea3..cae3be10 100644
--- a/lib/api/element-commands/getLocationInView.js
+++ b/lib/api/element-commands/getLocationInView.js
@@ -25,6 +25,10 @@ const BaseElementCommand = require('./_baseElementCommand.js');
  * @api protocol.elementlocation
  */
 class GetLocationInView extends BaseElementCommand {
+  get w3c_deprecated() {
+    return true;
+  }
+
   get extraArgsCount() {
     return 0;
   }
diff --git a/lib/api/expect/assertions/element/active.js b/lib/api/expect/assertions/element/active.js
index 73563d4d..a94d4242 100644
--- a/lib/api/expect/assertions/element/active.js
+++ b/lib/api/expect/assertions/element/active.js
@@ -34,9 +34,7 @@ class ActiveAssertion extends BaseAssertion {
   }
 
   compareElementIds() {
-    const activeElementId = this.client.transport.getElementId(this.resultValue);
-
-    return activeElementId === this.elementId;
+    return this.resultValue === this.elementId;
   }
 
   onResultSuccess() {
diff --git a/lib/api/protocol/cookie.js b/lib/api/protocol/cookie.js
index cd38569c..000446a5 100644
--- a/lib/api/protocol/cookie.js
+++ b/lib/api/protocol/cookie.js
@@ -17,14 +17,14 @@ module.exports = class Session extends ProtocolAction {
   command(method, callbackOrCookie) {
     switch (method) {
       case 'GET':
-        return this.transportActions.getCookieString(callbackOrCookie);
+        return this.transportActions.getCookies(callbackOrCookie);
 
       case 'POST':
         if (arguments.length < 2) {
           throw new Error('POST requests to /cookie must include a cookie object parameter also.');
         }
 
-        return this.transportActions.setCookieString(callbackOrCookie, arguments[2]);
+        return this.transportActions.addCookie(callbackOrCookie, arguments[2]);
 
       case 'DELETE':
         if (typeof callbackOrCookie === 'undefined' || typeof callbackOrCookie === 'function') {
diff --git a/lib/api/protocol/doubleClick.js b/lib/api/protocol/doubleClick.js
index 48f379a9..507261ef 100644
--- a/lib/api/protocol/doubleClick.js
+++ b/lib/api/protocol/doubleClick.js
@@ -7,7 +7,15 @@ const ProtocolAction = require('./_base-action.js');
  * @param {function} [callback] Optional callback function to be called when the command finishes.
  * @api protocol.useractions
  */
-module.exports = class Session extends ProtocolAction {
+module.exports = class DoubleClick extends ProtocolAction {
+  get w3c_deprecated() {
+    return true;
+  }
+
+  get deprecationNotice() {
+    return 'Nightwatch now supports the extended Selenium user actions API which is available via the the .perform() command.';
+  }
+
   command(callback) {
     return this.transportActions.doubleClick(callback);
   }
diff --git a/lib/api/protocol/elementIdEquals.js b/lib/api/protocol/elementIdEquals.js
index 7e11467d..b6145fa0 100644
--- a/lib/api/protocol/elementIdEquals.js
+++ b/lib/api/protocol/elementIdEquals.js
@@ -23,6 +23,14 @@ const ProtocolAction = require('./_base-action.js');
  * @api protocol.elements
  */
 module.exports = class Session extends ProtocolAction {
+  get w3c_deprecated() {
+    return true;
+  }
+
+  get deprecationNotice() {
+    return 'Please use WebElement.equals(a, b) instead from Selenium Webdriver.';
+  }
+
   command(webElementId, otherId, callback) {
     ProtocolAction.validateElementId(webElementId, 'elementIdEquals');
 
diff --git a/lib/api/protocol/elementIdLocation.js b/lib/api/protocol/elementIdLocation.js
index 226120e7..88fc029d 100644
--- a/lib/api/protocol/elementIdLocation.js
+++ b/lib/api/protocol/elementIdLocation.js
@@ -11,9 +11,17 @@ const ProtocolAction = require('./_base-action.js');
  * @returns {object} The X and Y coordinates for the element on the page.
  */
 module.exports = class Session extends ProtocolAction {
+  get w3c_deprecated() {
+    return true;
+  }
+
+  get deprecationNotice() {
+    return 'Please use .getElementRect().';
+  }
+
   command(webElementId, callback) {
     ProtocolAction.validateElementId(webElementId, 'elementIdLocation');
 
-    return this.transportActions.getElementLocation(webElementId, callback);
+    return this.transportActions.getElementRect(webElementId, callback);
   }
 };
diff --git a/lib/api/protocol/elementIdLocationInView.js b/lib/api/protocol/elementIdLocationInView.js
index 548d26c1..6826b16b 100644
--- a/lib/api/protocol/elementIdLocationInView.js
+++ b/lib/api/protocol/elementIdLocationInView.js
@@ -9,6 +9,10 @@ const ProtocolAction = require('./_base-action.js');
  * @api protocol.elementinternal
  */
 module.exports = class Session extends ProtocolAction {
+  get w3c_deprecated() {
+    return true;
+  }
+
   command(webElementId, callback) {
     ProtocolAction.validateElementId(webElementId, 'elementIdLocationInView');
 
diff --git a/lib/api/protocol/elementIdSize.js b/lib/api/protocol/elementIdSize.js
index a3e7190f..80dcfe9f 100644
--- a/lib/api/protocol/elementIdSize.js
+++ b/lib/api/protocol/elementIdSize.js
@@ -9,9 +9,17 @@ const ProtocolAction = require('./_base-action.js');
  * @internal
  */
 module.exports = class Session extends ProtocolAction {
+  get w3c_deprecated() {
+    return true;
+  }
+
+  get deprecationNotice() {
+    return 'Please use .getElementRect().';
+  }
+
   command(webElementId, callback) {
     ProtocolAction.validateElementId(webElementId, 'elementIdSize');
 
-    return this.transportActions.getElementSize(webElementId, callback);
+    return this.transportActions.getElementRect(webElementId, callback);
   }
 };
diff --git a/lib/api/protocol/elementIdValue.js b/lib/api/protocol/elementIdValue.js
index 62edc64d..d45bbfcf 100644
--- a/lib/api/protocol/elementIdValue.js
+++ b/lib/api/protocol/elementIdValue.js
@@ -11,6 +11,10 @@ const ProtocolAction = require('./_base-action.js');
  * @internal
  */
 module.exports = class Session extends ProtocolAction {
+  get w3c_deprecated() {
+    return true;
+  }
+
   command(webElementId, value, callback) {
     ProtocolAction.validateElementId(webElementId, 'elementIdValue');
 
diff --git a/lib/api/protocol/mouseButtonClick.js b/lib/api/protocol/mouseButtonClick.js
index 4d8f6f19..5323ad30 100644
--- a/lib/api/protocol/mouseButtonClick.js
+++ b/lib/api/protocol/mouseButtonClick.js
@@ -9,7 +9,15 @@ const ProtocolAction = require('./_base-action.js');
  * @param {function} [callback] Optional callback function to be called when the command finishes.
  * @api protocol.useractions
  */
-module.exports = class Session extends ProtocolAction {
+module.exports = class Command extends ProtocolAction {
+  get w3c_deprecated() {
+    return true;
+  }
+
+  get deprecationNotice() {
+    return 'Nightwatch now supports the extended Selenium user actions API which is available via the the .perform() command.';
+  }
+
   command(button, callback) {
     return this.mouseButtonHandler('mouseButtonClick', button, callback);
   }
diff --git a/lib/http/request.js b/lib/http/request.js
index 81802f40..c27211c8 100644
--- a/lib/http/request.js
+++ b/lib/http/request.js
@@ -202,9 +202,10 @@ class HttpRequest extends EventEmitter {
 
   logResponse(result) {
     let base64Data;
-    if (this.addtOpts.suppressBase64Data) {
+    const shouldSupressData = result.value && this.addtOpts.suppressBase64Data && result.value.length > 100;
+    if (shouldSupressData) {
       base64Data = result.value;
-      result.value = '';
+      result.value = `${base64Data.substr(0, 100)}...`;
       result.suppressBase64Data = true;
     }
 
@@ -220,7 +221,7 @@ class HttpRequest extends EventEmitter {
 
     Logger[logMethod](`  Response ${this.statusCode} ${this.reqOptions.method} ${this.hostname + this.reqOptions.path} (${this.elapsedTime}ms)`, result);
 
-    if (this.addtOpts.suppressBase64Data) {
+    if (shouldSupressData) {
       result.value = base64Data;
     }
   }
diff --git a/lib/settings/defaults.js b/lib/settings/defaults.js
index ee2f24bc..b0a20839 100644
--- a/lib/settings/defaults.js
+++ b/lib/settings/defaults.js
@@ -206,6 +206,9 @@ module.exports = {
   // Ignore network errors (e.g. ECONNRESET errors)
   report_network_errors: true,
 
+  // Interactive element commands such as "click" or "setValue" can be retried if an error occurred (such as an "element not interactable" error)
+  element_command_retries: 2,
+
   // Take error and failure screenshots during test execution
   screenshots: {
     enabled: false,
diff --git a/lib/transport/factory.js b/lib/transport/factory.js
index 52866689..567c0991 100644
--- a/lib/transport/factory.js
+++ b/lib/transport/factory.js
@@ -34,7 +34,7 @@ module.exports = class TransportFactory {
   }
 
   static getBrowserName(nightwatchInstance) {
-    const {settings, argv} = nightwatchInstance;
+    const {settings, argv = {}} = nightwatchInstance;
     let {browserName} = settings.desiredCapabilities;
 
     if (argv.chrome) {
@@ -45,20 +45,17 @@ module.exports = class TransportFactory {
       browserName = Browser.SAFARI;
     } else if (argv.edge) {
       browserName = Browser.EDGE;
+    } else if (BrowsersLowerCase[browserName.toLowerCase()]) {
+      browserName = BrowsersLowerCase[browserName.toLowerCase()];
     } else {
-      let browserLowerCaseName = browserName.toLowerCase();
-      browserName = BrowsersLowerCase[browserLowerCaseName];
+      const didYouMean = require('didyoumean');
+      const browsersList = Object.values(Browser);
+      const resultMeant = didYouMean(browserName, browsersList);
+  
+      throw new Error(`Unknown browser: "${browserName}"${resultMeant ? ('; did you mean "' + resultMeant + '"?') : ''}`);
     }
 
-    if (browserName) {
-      return browserName;
-    }
-
-    const didYouMean = require('didyoumean');
-    const browsersList = Object.values(Browser);
-    const resultMeant = didYouMean(browserName, browsersList);
-
-    throw new Error(`Unknown browser: "${browserName}"${resultMeant ? ('; did you mean "' + resultMeant + '"?') : ''}`);
+    return browserName;
   }
 
   static create(nightwatchInstance) {
diff --git a/lib/transport/index.js b/lib/transport/index.js
index 9ea1bdd2..353e9cbc 100644
--- a/lib/transport/index.js
+++ b/lib/transport/index.js
@@ -64,6 +64,7 @@ class Transport extends EventEmitter {
   constructor(nightwatchInstance) {
     super();
 
+    this.elementKey = Transport.WEB_ELEMENT_ID;
     this.nightwatchInstance = nightwatchInstance;
     this.init();
   }
diff --git a/lib/transport/selenium-webdriver/actions.js b/lib/transport/selenium-webdriver/actions.js
index 52883aa9..f8f1e8c3 100644
--- a/lib/transport/selenium-webdriver/actions.js
+++ b/lib/transport/selenium-webdriver/actions.js
@@ -36,27 +36,50 @@ class TransportActions extends BaseActions {
   }
 
   createAction(name, mapping) {
-    return (definition) => {
+    return async (definition) => {
       const args = definition.args;
+      let result;
       let promise;
 
-      if (Utils.isFunction(mapping)) {
-        promise = Array.isArray(args) ? mapping.apply(this.MethodMappings, args) : mapping.call(this.MethodMappings, args);
-      }
+      try {
+        if (Utils.isFunction(mapping)) {
+          promise = Array.isArray(args) ? mapping.apply(this.MethodMappings, args) : mapping.call(this.MethodMappings, args);
+        }
 
-      /*
-      if (Utils.isString(mapping)) {
-        promise = this.runAction(TransportActions.createOptions(requestOptions));
-      }
+        if (!(promise instanceof Promise)) {
+          const opts = {};
 
-      if (definition.sessionId) {
-        requestOptions.path = `/session/${definition.sessionId}${requestOptions.path}`;
-      } else if (definition.sessionRequired) {
-        throw new Error(`A session is required to run this command (${name}).`);
-      }
-      */
+          if (Utils.isString(promise)) {
+            opts.path = `/session/${definition.sessionId}${promise}`;
+          } else if (Utils.isObject(promise)) {
+            Object.assign(opts, promise);
+            opts.path = `/session/${definition.sessionId}${opts.path}`;
+          }
+
+          promise = this.transport.runProtocolAction(opts);
+        }
+
+        result = await promise;
+
+        if (Array.isArray(result) || !Utils.isObject(result)) {
+          return {
+            value: result,
+            status: 0
+          };
+        }
+
+        result.status = result.status || 0;
+
+        return result;
+      } catch (err) {
+        const error = this.handleError(err, name);
 
-      return promise.catch(result => this.handleError(result, name));
+        return {
+          error,
+          status: -1,
+          value: null
+        };
+      }
     };
 
   }
@@ -75,18 +98,6 @@ class TransportActions extends BaseActions {
 
     return err;
   }
-
-  runAction(requestOptions) {
-    console.log('RUN ACTION', requestOptions);
-
-    return Promise.resolve({});
-  }
-
-  static createOptions(uri) {
-    return {
-      path: uri
-    };
-  }
 }
 
 module.exports = TransportActions;
diff --git a/lib/transport/selenium-webdriver/index.js b/lib/transport/selenium-webdriver/index.js
index d0fa203c..5391af60 100644
--- a/lib/transport/selenium-webdriver/index.js
+++ b/lib/transport/selenium-webdriver/index.js
@@ -1,4 +1,4 @@
-const {By, Builder, Capabilities, Browser} = require('selenium-webdriver');
+const {By, Builder, Capabilities, Browser, error} = require('selenium-webdriver');
 const Element = require('../../element');
 const Logging = require('./logging.js');
 const Options = require('./options.js');
@@ -100,10 +100,12 @@ class SeleniumWebdriver extends WebdriverTransport {
     this.__capabilities = this.createCapabilities();
 
     this.createHttpClient();
+
     if (browserName) {
       this.capabilities.setBrowserName(browserName);
     }
 
+    this.elementKey = WebdriverTransport.WEB_ELEMENT_ID;
     // Logging.setupVerboseLogging({
     //   isSelenium
     // });
@@ -113,7 +115,7 @@ class SeleniumWebdriver extends WebdriverTransport {
   createHttpClient() {
     const url = require('url');
     const http = require('selenium-webdriver/http');
-
+    const {settings} = this.nightwatchInstance;
     // TODO: handle agent and proxy arguments below
 
     http.HttpClient = class HttpClient {
@@ -128,10 +130,15 @@ class SeleniumWebdriver extends WebdriverTransport {
         this.proxyOptions_ = opt_proxy ? {} : null;
 
         const {hostname: host, port, pathname: path, protocol} = options;
+        const {log_screenshot_data} = settings;
+
         this.options = {
           host,
           port,
           path,
+          addtOpts: {
+            suppressBase64Data: !log_screenshot_data
+          },
           use_ssl: protocol === 'https:'
         };
         this.errorTimeoutId = null;
@@ -163,7 +170,7 @@ class SeleniumWebdriver extends WebdriverTransport {
               try {
                 body = JSON.stringify(data);
               } catch (err) {
-
+                // 
               }
             }
             const resp = new http.Response(statusCode, headers, body);
@@ -251,7 +258,8 @@ class SeleniumWebdriver extends WebdriverTransport {
 
     this
       .addHeadlessOption({options, argv})
-      .addWindowSizeOption({options});
+      .addWindowSizeOption({options})
+      .addProxyOption({options});
 
     return options;
   }
@@ -272,6 +280,13 @@ class SeleniumWebdriver extends WebdriverTransport {
     return this;
   }
 
+  addProxyOption({options}) {
+    if (this.capabilities.getProxy() && (options instanceof Capabilities) && options.setProxy) {
+      const proxy = require('selenium-webdriver/proxy');
+      options.setProxy(proxy.manual(this.capabilities.getProxy()));
+    }
+  }
+
   setBuilderOptions({builder, options}) {
     switch (this.capabilities.getBrowserName()) {
       case Browser.CHROME:
@@ -341,13 +356,11 @@ class SeleniumWebdriver extends WebdriverTransport {
   createSessionHandler() {}
 
   staleElementReference(result) {
-    console.log(result);
-
-    return false;
+    return result.error instanceof error.StaleElementReferenceError;
   }
 
   isResultSuccess(result) {
-    return !(result instanceof Error);
+    return !((result instanceof Error) || (result.error instanceof Error) || result && result.status === -1);
   }
 
   async createSession(argv) {
@@ -363,6 +376,9 @@ class SeleniumWebdriver extends WebdriverTransport {
     const session = await this.driver.getSession();
     const sessionId = await session.getId();
     const capabilities = await session.getCapabilities();
+    const executor = await this.driver.getExecutor();
+
+    this.elementKey = executor.w3c ? WebdriverTransport.WEB_ELEMENT_ID : 'ELEMENT';
 
     return {
       sessionId,
diff --git a/lib/transport/selenium-webdriver/method-mappings.js b/lib/transport/selenium-webdriver/method-mappings.js
index c51c5a5b..b9158029 100644
--- a/lib/transport/selenium-webdriver/method-mappings.js
+++ b/lib/transport/selenium-webdriver/method-mappings.js
@@ -1,6 +1,5 @@
-const {until, WebElement} = require('selenium-webdriver');
+const {WebElement} = require('selenium-webdriver');
 const SeleniumWebdriver = require('./');
-const Transport = require('../');
 const {Logger, isString} = require('../../utils');
 
 module.exports = class MethodMappings {
@@ -31,18 +30,30 @@ module.exports = class MethodMappings {
       ///////////////////////////////////////////////////////////
       // Session related
       ///////////////////////////////////////////////////////////
-      sessionAction(action) {
+      async sessionAction(action) {
         switch (action) {
-          case 'DELETE':
-            return this.driver.quit();
+          case 'DELETE': {
+            await this.driver.quit();
+
+            return {
+              state: 'success',
+              value: null
+            };
+          }
+
 
           default:
             return this.driver.getSession();
         }
       },
 
-      getSessions: '/sessions',
-      getStatus: '/status',
+      getSessions() {
+        return '/sessions';
+      },
+
+      getStatus() {
+        return '/status';
+      },
 
       session: {
         ///////////////////////////////////////////////////////////
@@ -107,33 +118,23 @@ module.exports = class MethodMappings {
         async navigateTo(url) {
           await this.driver.navigate().to(url);
 
-          return {
-            value: null
-          };
+          return null;
         },
 
-        async getCurrentUrl() {
-          const url = await this.driver.getCurrentUrl();
-
-          return {
-            value: url
-          };
+        getCurrentUrl() {
+          return this.driver.getCurrentUrl();
         },
 
         async navigateBack() {
           await this.driver.navigate().back();
 
-          return {
-            value: null
-          };
+          return null;
         },
 
         async navigateForward() {
           await this.driver.navigate().forward();
 
-          return {
-            value: null
-          };
+          return null;
         },
 
         async pageRefresh() {
@@ -164,11 +165,7 @@ module.exports = class MethodMappings {
         },
 
         async closeWindow() {
-          await this.driver.close();
-
-          return {
-            value: null
-          };
+          return this.driver.close();
         },
 
         async getWindowHandle() {
@@ -222,16 +219,14 @@ module.exports = class MethodMappings {
           };
         },
 
-        async openNewWindow() {
-          // return TransportActions.post('/window/new');
-          await this.driver.switchTo().newWindow('window');
+        async openNewWindow(type = 'tab') {
+          await this.driver.switchTo().newWindow(type);
 
           return {
             value: null
           };
         },
 
-        //Kept windowHandle as params for backward comptability.
         async setWindowPosition(windowHandle, x, y) {
           await this.driver.manage().window().setRect({
             x,
@@ -244,13 +239,10 @@ module.exports = class MethodMappings {
         },
 
         async getWindowSize() {
-          const {width, height} = await this.driver.manage().window().getRect();
+          const value = await this.driver.manage().window().getRect();
 
           return {
-            value: {
-              width,
-              height
-            }
+            value
           };
         },
 
@@ -281,7 +273,6 @@ module.exports = class MethodMappings {
             value: null
           };
         },
-
         ///////////////////////////////////////////////////////////
         // Frames
         ///////////////////////////////////////////////////////////
@@ -312,9 +303,7 @@ module.exports = class MethodMappings {
         ///////////////////////////////////////////////////////////
         async locateSingleElement(element) {
           const locator = SeleniumWebdriver.createLocator(element);
-          //const {waitForConditionTimeout, waitForConditionPollInterval}
-
-          const webElement = await this.driver.wait(until.elementLocated(locator));
+          const webElement = await this.driver.findElement(locator);
           const elementId = await webElement.getId();
 
           return {
@@ -326,17 +315,26 @@ module.exports = class MethodMappings {
         async locateMultipleElements(element) {
           const locator = SeleniumWebdriver.createLocator(element);
           const resultValue = await this.driver.findElements(locator);
-          const resultProcessed = await Promise.all(resultValue.map(async webElement => {
+
+          if (Array.isArray(resultValue) && resultValue.length === 0) {
+            return {
+              status: -1,
+              value: [],
+              error: `unable to locate element using ${locator.using}`
+            };
+          }
+
+          const {elementKey} = this.transport;
+          const value = await Promise.all(resultValue.map(async webElement => {
             const elementId = await webElement.getId();
 
-            return {[Transport.WEB_ELEMENT_ID]: elementId};
+            return {[elementKey]: elementId};
           }));
 
-          return {
-            value: resultProcessed
-          };
+          return value;
         },
 
+
         elementIdEquals(id, otherId) {
           return `/element/${id}/equals/${otherId}`;
         },
@@ -344,13 +342,12 @@ module.exports = class MethodMappings {
         async locateSingleElementByElementId({id, value}) {
           const locator = SeleniumWebdriver.createLocator(value);
           const element = await this.getWebElement(id);
-
           const webElement = await element.findElement(locator);
-
           const elementId = await webElement.getId();
 
           return {
             value: webElement,
+            status: 0,
             elementId
           };
         },
@@ -360,55 +357,40 @@ module.exports = class MethodMappings {
           const element = await this.getWebElement(id);
           const resultValue = await element.findElements(locator);
 
+          const {elementKey} = this.transport;
           const resultProcessed = await Promise.all(resultValue.map(async webElement => {
             const elementId = await webElement.getId();
 
-            return {[Transport.WEB_ELEMENT_ID]: elementId};
+            return {[elementKey]: elementId};
           }));
 
-          return {
-            value: resultProcessed
-          };
+          return resultProcessed;
         },
 
         async getActiveElement() {
-          try {
-            const activeElement = await this.driver.switchTo().activeElement();
-
-            return {
-              value: activeElement
-            };
-          } catch (error) {
-            Logger.error(error);
+          const webElement = await this.driver.switchTo().activeElement();
+          const elementId = await webElement.getId();
 
-            return {
-              error,
-              status: -1
-            };
-          }
+          return elementId;
         },
 
         async getElementAttribute(webElement, attributeName) {
           const element = this.getWebElement(webElement);
           const elementValue = await element.getAttribute(attributeName);
 
-          return {
-            value: elementValue
-          };
+          return elementValue;
         },
 
         async getElementCSSValue(id, cssPropertyName) {
           const element = this.getWebElement(id);
           const elementCssValue = await element.getCssValue(cssPropertyName);
 
-          return {
-            value: elementCssValue
-          };
+          return elementCssValue;
         },
 
         async getElementProperty(webElement, propertyName) {
           const element = this.getWebElement(webElement);
-          const elementValue = await element.getAttribute(propertyName);
+          const elementValue = await element.getProperty(propertyName);
 
           return {
             value: elementValue
@@ -424,12 +406,13 @@ module.exports = class MethodMappings {
           };
         },
 
-        async getElementSize(id) {
+        async getElementRect(id) {
           const element = this.getWebElement(id);
-          const elementSize = await element.getRect();
+          const value = await element.getRect();
 
           return {
-            value: elementSize
+            value,
+            status: 0
           };
         },
 
@@ -452,18 +435,6 @@ module.exports = class MethodMappings {
           };
         },
 
-        async getElementLocation(id) {
-          const element = this.getWebElement(id);
-          const {x, y} = await element.getRect();
-
-          return {
-            value: {
-              x,
-              y
-            }
-          };
-        },
-
         isElementLocationInView(id) {
           return `/element/${id}/location_in_view`;
         },
@@ -505,30 +476,22 @@ module.exports = class MethodMappings {
         },
 
         async isElementSelected(webElement) {
-          try {
-            const element = this.getWebElement(webElement);
-            const value = await element.isSelected();
-
-            return {
-              value
-            };
-          } catch (error) {
-            Logger.error(error);
+          const element = this.getWebElement(webElement);
+          const value = await element.isSelected();
 
-            return {
-              error,
-              status: -1
-            };
-          }
+          return value;
         },
 
         async clearElementValue(webElement) {
           const element = this.getWebElement(webElement);
           await element.clear();
 
-          return {
-            value: null
-          };
+          return null;
+        },
+
+        setElementValueRedacted(...args) {
+          // FIXME: redact password in verbose HTTP logs, it's only redacted in the command logs
+          return this.methods.session.setElementValue.call(this, ...args);
         },
 
         async setElementValue(webElement, value) {
@@ -546,8 +509,6 @@ module.exports = class MethodMappings {
               value: null
             };
           } catch (error) {
-            Logger.error(error);
-
             return {
               error,
               status: -1
@@ -556,21 +517,10 @@ module.exports = class MethodMappings {
         },
 
         async clickElement(webElement) {
-          try {
-            const element = this.getWebElement(webElement);
-            await element.click();
-
-            return {
-              value: null
-            };
-          } catch (error) {
-            Logger.error(error);
+          const element = this.getWebElement(webElement);
+          await element.click();
 
-            return {
-              error,
-              status: -1
-            };
-          }
+          return null;
         },
 
         async elementSubmit(webElement) {
@@ -582,8 +532,6 @@ module.exports = class MethodMappings {
               value: null
             };
           } catch (error) {
-            Logger.error(error);
-
             return {
               error,
               status: -1
@@ -592,18 +540,21 @@ module.exports = class MethodMappings {
         },
 
         sendKeys(keys) {
-          return TransportActions.post({
+          return {
+            method: 'POST',
             path: '/keys',
             data: {
               value: keys
             }
-          });
+          };
         },
 
         ///////////////////////////////////////////////////////////
         // Document Handling
         ///////////////////////////////////////////////////////////
-        getPageSource: '/source',
+        getPageSource() {
+          return '/source';
+        },
 
         async executeScript(script, args) {
           const value = await this.driver.executeScript(script, args);
@@ -624,8 +575,7 @@ module.exports = class MethodMappings {
         ///////////////////////////////////////////////////////////
         // Cookies
         ///////////////////////////////////////////////////////////
-
-        async setCookieString(cookie) {
+        async addCookie(cookie) {
           await this.driver.manage().addCookie(cookie);
 
           return {
@@ -649,7 +599,7 @@ module.exports = class MethodMappings {
           };
         },
 
-        async getCookieString() {
+        async getCookies() {
           const value = await this.driver.manage().getCookies();
 
           return {
@@ -661,58 +611,55 @@ module.exports = class MethodMappings {
         // User Actions
         ///////////////////////////////////////////////////////////
         /**
-         *
-         * @param {WebElement|null|undefined} element
-         * @param {{async: (boolean|undefined), bridge: (boolean|undefined)}} options
+         * @deprecated
          */
-        async doubleClick(element, options) {
-
-          await this.driver.actions(options).doubleClick(element);
-
+        doubleClick() {
           return {
-            value: null
+            path: '/doubleclick',
+            method: 'POST'
           };
         },
 
         /**
-         *
-         * @param {WebElement|null|undefined} element
-         * @param {{async: (boolean|undefined), bridge: (boolean|undefined)}} options
+         * @deprecated
          */
-        async mouseButtonClick(element, options) {
-          await this.driver.actions(options).click(element);
-
+        mouseButtonClick(buttonIndex) {
           return {
-            value: null
+            method: 'POST',
+            path: '/click',
+            data: {
+              button: buttonIndex
+            }
           };
         },
 
         mouseButtonUp(buttonIndex) {
-          return TransportActions.post({
+          return {
+            method: 'POST',
             path: '/buttonup',
             data: {
               button: buttonIndex
             }
-          });
+          };
         },
 
         mouseButtonDown(buttonIndex) {
-          return TransportActions.post({
+          return {
+            method: 'POST',
             path: '/buttondown',
             data: {
               button: buttonIndex
             }
-          });
+          };
         },
 
-        //TODO: update parameters
         /**
          *
-         * @param {{async: (boolean|undefined), bridge: (boolean|undefined)}} options
-         * @param {number|undefined} duration
-         * @param {Origin|WebElement|undefined} origin
-         * @param {number|undefined} xOffset
-         * @param {number|undefined} yOffset
+         * @param {object} options
+         * @param {number} duration
+         * @param {object} origin
+         * @param {number} xOffset
+         * @param {number} yOffset
          */
         async moveTo(options, duration, origin, xOffset, yOffset) {
           await this.driver.actions(options).move({duration, origin, xOffset, yOffset});
@@ -720,8 +667,6 @@ module.exports = class MethodMappings {
           return {
             value: null
           };
-
-
         },
 
         ///////////////////////////////////////////////////////////
@@ -730,73 +675,68 @@ module.exports = class MethodMappings {
         async acceptAlert() {
           await this.driver.switchTo().alert().accept();
 
-          return {
-            value: null
-          };
+          return null;
         },
 
         async dismissAlert() {
           await this.driver.switchTo().alert().dismiss();
 
-          return {
-            value: null
-          };
+          return null;
         },
 
-        async getAlertText() {
-          const value = await this.driver.switchTo().alert().getText();
-
-          return {
-            value
-          };
+        getAlertText() {
+          return this.driver.switchTo().alert().getText();
         },
 
         async setAlertText(keys) {
-          const alert = await this.driver.switchTo().alert();
-          await alert.sendKeys(keys);
-          const value = await alert.accept();
+          await this.driver.switchTo().alert().sendKeys(keys);
 
-          return {
-            value
-          };
+          return null;
         },
 
         ///////////////////////////////////////////////////////////
         // Screen
         ///////////////////////////////////////////////////////////
-        getScreenshot(logBase64Data) {
-          return Promise.resolve('');
+        async getScreenshot(logBase64Data) {
+          const data = await this.driver.takeScreenshot();
 
           return {
-            path: '/screenshot',
-            addtOpts: {
-              suppressBase64Data: !logBase64Data
-            }
+            value: data,
+            status: 0,
+            suppressBase64Data: !logBase64Data
           };
         },
 
-        getScreenOrientation: '/orientation',
+        getScreenOrientation() {
+          return '/orientation';
+        },
 
         setScreenOrientation(orientation) {
-          return TransportActions.post({
+          return {
+            method: 'POST',
             path: '/orientation',
             data: {
-              orientation: orientation
+              orientation
             }
-          });
+          };
         },
 
-        getAvailableContexts: '/contexts',
+        getAvailableContexts() {
+          return '/contexts';
+        },
 
-        getCurrentContext: '/context',
+        getCurrentContext() {
+          return '/context';
+        },
 
         setCurrentContext(context) {
-          return TransportActions.post({
+          return {
+            method: 'POST',
             path: '/context',
             data: {
               name: context
             }
-          });
+          };
         },
 
         ///////////////////////////////////////////////////////////////////////////
diff --git a/lib/transport/webdriver/index.js b/lib/transport/webdriver/index.js
index 6462de9d..646e2277 100644
--- a/lib/transport/webdriver/index.js
+++ b/lib/transport/webdriver/index.js
@@ -14,11 +14,11 @@ class WebdriverProtocol extends Transport {
   // Elements related
   ////////////////////////////////////////////////////////////////////
   getElementId(resultValue) {
-    return resultValue[Transport.WEB_ELEMENT_ID];
+    return resultValue[this.elementKey];
   }
 
   toElement(resultValue) {
-    return {[Transport.WEB_ELEMENT_ID]: resultValue};
+    return {[this.elementKey]: resultValue};
   }
 
   isResultSuccess(result) {
diff --git a/lib/utils/periodic-promise.js b/lib/utils/periodic-promise.js
index c28dc564..d31bbe56 100644
--- a/lib/utils/periodic-promise.js
+++ b/lib/utils/periodic-promise.js
@@ -129,12 +129,13 @@ class PeriodicPromise extends EventEmitter {
   shouldRetry({retryOnFailure, retryOnSuccess, shouldRetryOnError, isValidResult, currentResult}) {
     const now = new Date().getTime();
     const timePassed = now - this.startTime >= this.ms;
+    const retryOnFailureResult = typeof retryOnFailure == 'function' ? retryOnFailure() : retryOnFailure;
 
     if (timePassed) {
       return false;
     }
 
-    if (retryOnFailure && !isValidResult) {
+    if (retryOnFailureResult && !isValidResult) {
       return shouldRetryOnError(currentResult);
     }
 


Test patch:
diff --git a/test/lib/fakedriver.js b/test/lib/fakedriver.js
new file mode 100644
index 00000000..1300befe
--- /dev/null
+++ b/test/lib/fakedriver.js
@@ -0,0 +1,247 @@
+const CommandsExecutor = {
+  findChildElement(args, assertion) {
+    assertion({args, command: 'findChildElement'});
+
+    return fakeWebElement(TEST_CHILD_ELEMENT_ID);
+  },
+
+  findChildElements(args, assertion) {
+    assertion({args, command: 'findChildElements'});
+
+    return [
+      fakeWebElement(TEST_CHILD_ELEMENT_ID)
+    ];
+  },
+
+  clearElement(args, assertion) {
+    assertion({args, command: 'clearElement'});
+
+    return null;
+  },
+
+  isElementSelected(args, assertion) {
+    assertion({args, command: 'isElementSelected'});
+
+    return true;
+  },
+
+  isElementEnabled(args, assertion) {
+    assertion({args, command: 'isElementEnabled'});
+
+    return true;
+  },
+
+  isElementDisplayed(args, assertion) {
+    assertion({args, command: 'isElementDisplayed'});
+
+    return true;
+  },
+
+  getElementAttribute(args, assertion) {
+    assertion({args, command: 'getElementAttribute'});
+
+    return 'test_value';
+  },
+
+
+  getElementProperty(args, assertion) {
+    assertion({args, command: 'getElementProperty'});
+
+    return 'test_prop_value';
+  },
+
+  getElementTagName(args, assertion) {
+    assertion({args, command: 'getElementTagName'});
+
+    return 'div';
+  },
+
+  getElementText(args, assertion) {
+    assertion({args, command: 'getElementText'});
+
+    return 'text';
+  },
+
+  clickElement(args, assertion) {
+    assertion({args, command: 'clickElement'});
+
+    return null;
+  },
+
+  getElementRect(args, assertion) {
+    assertion({args, command: 'getElementRect'});
+
+    return {
+      width: 100,
+      height: 105,
+      x: 10,
+      y: 15
+    };
+  },
+
+  getElementValueOfCssProperty(args, assertion) {
+    assertion({args, command: 'getElementValueOfCssProperty'});
+
+    return '';
+  },
+
+  sendKeysToElement(args, assertion) {
+    assertion({args, command: 'sendKeysToElement'});
+
+    return null;
+  }
+};
+
+const fakeWebElement = function(elementId) {
+  return {
+    getId() {
+      return Promise.resolve(elementId);
+    }
+  };
+};
+
+const TEST_ELEMENT_ID = '12345-6789';
+const TEST_CHILD_ELEMENT_ID = '6789-192111';
+
+const createElementCommandMocks = function(assertion) {
+  return {
+    findElement(locator) {
+      assertion({locator, command: 'findElement'});
+
+      return fakeWebElement(TEST_ELEMENT_ID);
+    },
+
+    findElements(locator) {
+      assertion({locator, command: 'findElements'});
+
+      const element = fakeWebElement(TEST_ELEMENT_ID);
+      return [
+        element
+      ];
+    }
+  };
+};
+
+const createManageCommandMocks = function(assertion) {
+  return {
+    manage() {
+      return {
+        addCookie(cookie) {
+          assertion(cookie);
+        },
+        deleteCookie(cookie) {
+          assertion(cookie);
+        },
+        deleteAllCookies() {
+          assertion({
+            command: 'deleteAllCookies'
+          });
+        },
+        getCookies() {
+          assertion('cookie-test');
+          return Promise.resolve();
+        },
+
+        window() {
+          return {
+            setRect(...args) {
+              assertion({
+                args
+              });
+
+              return Promise.resolve({value: null});
+            },
+            getRect(...args) {
+              return Promise.resolve({
+                x: 10,
+                y: 10,
+                width: 100,
+                height: 100
+              });
+            }
+          };
+        }
+      };
+    }
+  };
+};
+
+const createNavigateCommandMocks = function(assertion) {
+  return {
+    navigate() {
+      return {
+        to(url) {
+          assertion(url);
+        },
+        back() {
+          assertion();
+        },
+        refresh() {
+          assertion();
+        },
+        forward() {
+          assertion();
+        }
+      };
+    },
+    getCurrentUrl() {
+      assertion('http://localhost');
+      return 'http://localhost';
+    }
+  };
+};
+
+module.exports = {
+  fakeWebElement,
+  create(assertion, mockDriverOverrides) {
+    const driver = {
+      execute(command) {
+        const commandName = command.getName();
+        const params = command.getParameters();
+
+        let result = CommandsExecutor[commandName](params, assertion);
+        if (!(result instanceof Promise)) {
+          result = Promise.resolve(result);
+        }
+
+        return result;
+      },
+      switchTo() {
+        return {
+          activeElement() {
+            assertion({command: 'activeElement'});
+
+            return fakeWebElement(TEST_ELEMENT_ID);
+          },
+          alert() {
+            return {
+              accept() {
+                assertion();
+                return null;
+              },
+              dismiss() {
+                assertion();
+                return null;
+              },
+              getText() {
+                assertion('alert text');
+                return Promise.resolve('alert text');
+              },
+              sendKeys(value) {
+                assertion(value);
+                return null;
+              }
+            };
+          }
+        };
+      }
+    };
+
+    Object.assign(driver, createElementCommandMocks(assertion));
+    Object.assign(driver, createNavigateCommandMocks(assertion));
+    Object.assign(driver, createManageCommandMocks(assertion));
+    Object.assign(driver, mockDriverOverrides);
+
+    return driver;
+  }
+};
\ No newline at end of file
diff --git a/test/lib/globals.js b/test/lib/globals.js
index 351e9da6..ffb9b367 100644
--- a/test/lib/globals.js
+++ b/test/lib/globals.js
@@ -2,6 +2,8 @@ const fs = require('fs');
 const path = require('path');
 const assert = require('assert');
 const lodashMerge = require('lodash.merge');
+const {Session, WebDriver} = require('selenium-webdriver');
+const FakeDriver = require('./fakedriver.js');
 const common = require('../common.js');
 const Nightwatch = require('../lib/nightwatch.js');
 const MockServer  = require('../lib/mockserver.js');
@@ -9,6 +11,8 @@ const Settings = common.require('settings/settings.js');
 const Runner = common.require('runner/runner.js');
 const Reporter = common.require('reporter/index.js');
 
+const SESSION_ID = 'test_session_id';
+
 class ExtendedReporter extends Reporter {
   registerPassed(message) {
     this.assertionMessage = message;
@@ -23,6 +27,45 @@ class ExtendedReporter extends Reporter {
   }
 }
 
+class FakeExecutor {
+  constructor() {
+    this.commands_ = new Map()
+  }
+
+  execute(command) {
+    let expectations = this.commands_.get(command.getName())
+    if (!expectations || !expectations.length) {
+      assert.fail('unexpected command: ' + command.getName())
+      return
+    }
+
+    let next = expectations[0]
+    let result = next.execute(command)
+    if (next.times_ !== Infinity) {
+      next.times_ -= 1
+      if (!next.times_) {
+        expectations.shift()
+      }
+    }
+    return result
+  }
+
+  expect(commandName, opt_parameters) {
+    if (!this.commands_.has(commandName)) {
+      this.commands_.set(commandName, [])
+    }
+    let e = new Expectation(this, commandName, opt_parameters)
+    this.commands_.get(commandName).push(e)
+    return e
+  }
+
+  createDriver() {
+    let session = new Session(SESSION_ID, {});
+
+    return new WebDriver(session, this);
+  }
+}
+
 class Globals {
   runGroupGlobal(client, hookName, done) {
     const groupGlobal = path.join(__dirname, './globals/', client.currentTest.group.toLowerCase() + '.js');
@@ -91,34 +134,14 @@ class Globals {
     return this.runProtocolTest(definition, this.wdClient);
   }
 
-  runProtocolTest({assertion = function() {}, commandName, args = []}, client) {
+  runProtocolTest({assertion = function() {}, commandName, args = [], mockDriverOverrides = {}}, client) {
     return new Promise((resolve, reject) => {
-      client.transport.driver = {
-        manage() {
-          return {
-            window() {
-              return {
-                setRect(...args) {
-                  assertion({
-                    args
-                  });
-
-                  return Promise.resolve({value: null});
-                },
-                getRect(...args) {
-                  return Promise.resolve({
-                    x: 10,
-                    y: 10,
-                    width: 100,
-                    height: 100
-                  });
-                }
-              };
-            }
-          };
-        }
+      client.transport.runProtocolAction = function(opts) {
+        assertion(opts);
       };
 
+      client.transport.driver = FakeDriver.create(assertion, mockDriverOverrides);
+
       client.queue.once('queue:finished', err => {
         if (err) {
           reject(err);
diff --git a/test/lib/globals/commands.js b/test/lib/globals/commands.js
index 2dcb79b0..f8b3dea0 100644
--- a/test/lib/globals/commands.js
+++ b/test/lib/globals/commands.js
@@ -14,7 +14,7 @@ module.exports = {
           port: 10195,
           start_process: false
         },
-        // output: process.env.VERBOSE === '1' || false,
+        //output: process.env.VERBOSE === '1' || false,
         output: true,
         silent: false
       })
diff --git a/test/lib/nightwatch.js b/test/lib/nightwatch.js
index f50899d6..212b0886 100644
--- a/test/lib/nightwatch.js
+++ b/test/lib/nightwatch.js
@@ -112,6 +112,22 @@ module.exports = new function () {
     });
   };
 
+  this.initW3CClient = function(opts = {}) {
+    const settings = Object.assign({
+      selenium: {
+        version2: false,
+        start_process: false,
+        host: null
+      },
+      webdriver: {
+        start_process: false,
+        host: 'localhost'
+      }
+    }, opts);
+
+    return this.initClient(settings);
+  };
+
   this.initClient = function(options, reporter) {
     let client = this.createClient(options, reporter);
 
diff --git a/test/src/api/commands/testEnd.js b/test/src/api/commands/client/testEnd.js
similarity index 94%
rename from test/src/api/commands/testEnd.js
rename to test/src/api/commands/client/testEnd.js
index 8d444e16..0581fe84 100644
--- a/test/src/api/commands/testEnd.js
+++ b/test/src/api/commands/client/testEnd.js
@@ -1,7 +1,7 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const Nightwatch = require('../../../lib/nightwatch.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const Nightwatch = require('../../../../lib/nightwatch.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('.end()', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testInit.js b/test/src/api/commands/client/testInit.js
similarity index 90%
rename from test/src/api/commands/testInit.js
rename to test/src/api/commands/client/testInit.js
index 054e5e16..51c21805 100644
--- a/test/src/api/commands/testInit.js
+++ b/test/src/api/commands/client/testInit.js
@@ -1,5 +1,5 @@
 const assert = require('assert');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('init', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testLocateStrategy.js b/test/src/api/commands/client/testLocateStrategy.js
similarity index 90%
rename from test/src/api/commands/testLocateStrategy.js
rename to test/src/api/commands/client/testLocateStrategy.js
index cf501e6c..a8f52c84 100644
--- a/test/src/api/commands/testLocateStrategy.js
+++ b/test/src/api/commands/client/testLocateStrategy.js
@@ -1,5 +1,5 @@
 const assert = require('assert');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('locateStrategies', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testPause.js b/test/src/api/commands/client/testPause.js
similarity index 81%
rename from test/src/api/commands/testPause.js
rename to test/src/api/commands/client/testPause.js
index ee04d8eb..d5d9ef24 100644
--- a/test/src/api/commands/testPause.js
+++ b/test/src/api/commands/client/testPause.js
@@ -1,4 +1,4 @@
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('pause', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testPerform.js b/test/src/api/commands/client/testPerform.js
similarity index 93%
rename from test/src/api/commands/testPerform.js
rename to test/src/api/commands/client/testPerform.js
index 7c32a965..8480b41c 100644
--- a/test/src/api/commands/testPerform.js
+++ b/test/src/api/commands/client/testPerform.js
@@ -1,5 +1,5 @@
 const assert = require('assert');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('perform', function () {
   before(function (done) {
diff --git a/test/src/api/commands/client/testSaveScreenshot.js b/test/src/api/commands/client/testSaveScreenshot.js
new file mode 100644
index 00000000..77085863
--- /dev/null
+++ b/test/src/api/commands/client/testSaveScreenshot.js
@@ -0,0 +1,43 @@
+const assert = require('assert');
+const MockServer  = require('../../../../lib/mockserver.js');
+const common = require('../../../../common.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
+const {Screenshots} = common.require('utils');
+
+describe('saveScreenshot', function() {
+  before(function(done) {
+    CommandGlobals.beforeEach.call(this, done);
+  });
+
+  after(function(done) {
+    CommandGlobals.afterEach.call(this, done);
+  });
+
+  it('client.saveScreenshot()', function(done) {
+    const base64Image = 'iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAIAAABEtEjdAAAACXBIWXMAAA7zAAAO8wEcU5k6AAAAEXRFWHRUaXRsZQBQREYgQ3JlYXRvckFevCgAAAATdEVYdEF1dGhvcgBQREYgVG9vbHMgQUcbz3cwAAAALXpUWHREZXNjcmlwdGlvbgAACJnLKCkpsNLXLy8v1ytISdMtyc/PKdZLzs8FAG6fCPGXryy4AAPW0ElEQVR42uy9Z5djV3Yl+ByAB+9deG8yMzLSMA1tkeWk6pJKKmla06MlafRB3/UX9BP0eTSj1RpperpLKpXKscgii0xDZpLpIyMiM7yPQCCAgLfPzr73AUikYVVR00sqUvcwVxABIICHB2Dfc/fZZx/eNE2OBQsWLFh8uUJgp4AFCxYsGLizYMGCBQsG7ixYsGDBgoE7CxYsWLBg4M6CBQsWLBi4s2DBggUDdxYsWLBgwcCdBQsWLFgwcGfBggULFgzcWbBgwYIFA3cWLFiwYODOggULFiwYuLNgwYIFCwbuLFiwYMGCgTsLFixYsGDgzoIFCxYsGLizYMGCBQN3FixYsGDBwJ0FCxYsWDBwZ8GCBQsWDNxZsGDBggUDdxYsWLBg4M6CBQsWLBi4s2DBggULBu4sWLBgwYKBOwsWLFiwYODOggULFiwYuLNgwYIFA3cWLFiwYMHAnQULFixYMHBnwYIFCxYM3FmwYMGCBQN3FixYsGDgzoIFCxYsGLizYMGCBQsG7ixYsGDBgoE7CxYsWLBg4M6CBQsWLBi4s2DBggUDdxYsWLBgwcCdBQsWLFgwcGfBggULFgzcWbBgwYIFA3cWLFiwYODOggULFiwYuLNgwYIFCwbuLFiwYMHi3zokdgpY/FuG/oLrjK4Uw+hc4lv315/LRfjnHsHsuoftcx0P/8Jrzc+4jOMRtBclRoLJvmAsGLizYPE0NAodTOe7LrdvE1/0R93Aavz/O5AXgTXf/tV8Fv6F5za7xnOLhMneXRa/AcGbJvsosvi3C/MzE2fjV68CvxI4+c8NrDynfs7MXnj+qF74pNbrEdlbzoKBOwuG9//KO3Tf9wlt8q9/ev7FsG7dXfocCwELFv9+wWgZFr95gG4+jZj85/rzz5us2D7XQ/DmZyO7yRCfBQN3Fv/Rd4yfAaKfdQ3/6yIm/znR1DQ/J/6an3EMJoNyFgzcWfyHTtnBRQv8Z+Hj8+DIW9y18auy6s5ffj51L99+SJP/9f/g107PGdazYODO4j9IGJ8NwDz/QgB/BtZ/Vd3V/JytG60nNZ7DYcN88YbC9vnwnQULBu4svmxJOo02cJPABc0E+hpmG8itO9DbeKF1TRfKc1YB06R/a3Ql2fxnpu0muaNp0IdrPSJn6hwv0T82n1tY+ObzGwfT1Dh6SO3lxTBNXSCPiOsIR28YTxYkXngW/s2uI2SYz+LfK5hahsW/aaifAXyarlkoL/K8wAtdH9DOUkF/FZ5K5+nyYX2GBfqAPK9a8NuGa6NLjai3wd1aKSwwtzW7l6MWYwTwFgR6hcF3HYxu6KLgemoBo/c1DIMcBw5eFAD3RmdN0XWHyPInFgzcWXyJQtM0viusjxl+6vyz2b1FqYiC+BRqI/nWdICmYMitnFzkhDZMA0sFke/gq6FTWBYI9Bs1DZCq0sAFC3ZxL6fTics4EjsNwDBnpfbNJidJFMrN9qPwLemLQZcOod23pJt4UdhIWFsQ63UJ1hrQtToYZFtC7mKR+IJpbTtYsGDgzuLLzdV05eFt1DO6eByd0iFdaKhKTzJ85Mi6oWpNTVNqtRruCbxuNtV6va40gekEu7VmQVGUZrOJx5IkyWazWc8CQG/SsK7Hrw6HAz9lIYBfRZvNulKWXaJNslYjySZw9vZBd/gc24s6Wk1B1VQAvSiypiUWDNxZ/IfC9A75bj5dNgXxoaumbogSxXTKihiqWqtVqtWq0mgUsgqSY4A+MB0ZuSCaokiwF6htAbTN5hAESeAlkYTk9ds5kpULLXaFPKbwJK+2lg1VVer1RqNBMvGGBz8B+vhVaaqaoSsktIaiOJ1up9tlkxx4XDwdLjudLldAtX7lke/zrWchFD9+7TgW6ISQAdbz0vNuBa1ShCAwzz4WDNxZ/Cah87MfoM/gHICYHe6iU00loVjceYd413FXQ1MqFaB5pVjIAdMB4gBuECn46fc4ZVkGhguiwYuWLZjB6SqBbItCMSnJTdQuFqPS3gdYdwC+k8fXBAvxAcG4gNeCw8NPkmi7WsuATqFfJLQLeUDcQTcB99VGvVrBPqGGBUCjqwHAnaT4suxBuH0ul1uw2w1VF/Dgkv3pHQpniuYzZ4mBOwsG7iy+wOBuPsc14xqwKKIuck2lRqC8ivQc/0jKrDZ8Pq/ssAEtfT6PwyUTFKYENieVwMdzkK80arrWaDarpXKhXC4eHBzoNEh2ziGVBsciI6HeP8yTB1QUJPVerxc/cRm8DdYJi64BFw909vl8yWQyEom47IROwaHq0PHwYG9ku0MGQyN7vXhUAtat9NzaByDr9+qNRqVSK5VK1Uodj6kjTzc5t9uL1cjr9fu8AZvLxVklAZPTRf3Z5e1FJ4cFCwbuLL4Y4N4J4C8gtU4DwFo/KIAxB8oDiP1+bzDkd/v9nN1GZTEGzcrh8quYzUaz3sD9d3ZvVCqlo6PD9FGqXC40mkDVQrFY4AWTgHWDVE3B0ABbkUQDynNVrkHDegpgukh5nHK5jF9xB0A58m/c2mJ1uENcQMJOrtQB5lhgfE7Z5fJ4w+FoNB4PBsOy0+V2u32+AH4K2jDJ90kNlspgNINTDVRac4VCuVQtFEpYPvCwfl/Q7/cju5ciLqEd7FPEgoE7i/+JqPzMG/55705YDqAX5Ilgx7mOGBEQTFkRvXU3qGDafUDIY1WTkxxcVatmq8fpUiFX0RqmW/YhsXX0V/0Br+TzcrxGOBlIF034MjY5Qctm9ra213Z21/cPd/P541qd8DPp7Gy9jnRbtwF3bU7Cm0gOu01G7gs0pul/DWAai8Wi0ShyZ87lQE5dLBZJkq5rQHbsBpBPA7sJiAuCpZ/Bz0qtCsRPF/cB2X5PSLa7eY1XGyrodggzRVMz1JqhVjijbhc1l8wHgq6A39c/RfYHHo8rEvZHo5FQwIdUnxPAFoGQcXCmzCmiWlRyx9VsJl8p1W3KqM/njiSCgbjEeaEKwvmsc4KC1B7HYZgSLzhxslRaHSCEUFuNyeMguCrPNSRk/4R7ElpPYbjJmTbaak77c+9s91vMd/d8WZeZNJOBO4svHbb/OkSARpnnTj8RmBGelAsNodNGBOk3pOOE7DaRkDtcpmroPAqikpszbWpVKx6Xq8Xa7va2XQKG28MhfyTs5X1ODuwzcNxxTPDF1Bvl6nE2nzrMHBwcHudKa2vrtYZWKVNyW4GMUgRSkww6OkAB2hcKRTxuv8PhlMHayG5JtBMuhagedaA2yByXy0XEKrLNKpAiWum5ywk4xj0hg+FoMYBKHE3sJPBkxUbDCSJGlrF0cLqmKyoKAKi4FnM5pVFp1spKs9qs15RGVcf1nHFU2IOuBkJMCHZUtely2qPRMDB+aGAw4Pci1Y8EQzanh6xtJASuqteL5XT6KHtcrDcNtyeQ6OmPxhKSbOPtdFXE2SXgDVTXsVuxO3wWEPOk19akHbcG7Yoi7BM1NZZasG7p9H+5PId/vqGXbSAYuLP4MibubeD4zC+8otEqI9+6lsIK/un0oUzak88T8Tcwx5Kdm3WAk6ma+Ux5Zzt1nC3JdmcgEBgfG7I7kWjqnIg7VMk/rgYdTKNR290/WFx4tLK8dZTO1xqm2hQ0FTR1xO0Mef0xlxwkjUK8zSl7oFcJDtWAz6BcgO9QxWChgVYFEI9dBCAbXAc+wLTCicsASgMcic1GDgyKF/x0OCRcj7xYsgqlBq2k0moraqNkATBlgb4UkkljaTOanIGfioryKRYZRcMrRYMrdg/1ah2bgVpToYuKWq/WiqV8sXBcrRY1BeR72Wbn3E7B55MjUd/gQHJkdDAej9qdJU4A0Hs5062V+KOjRi7brNVMrycYCAX9AbckQ3OpC7JJGrzI5BAvPfuC1W2L12uarQau1vtC8Bo7I4W+KbgcetHb3oXpz/gxMKqfgTuLLwu4Gy/+zj8B8KdCb19jWjDCQzwOeCD31SkrDR7burlZM4vFci2rZrPpfCHj9shDw8megSiYA86sgX8w1apuKEhzkeFu7+0uLi5ub29njyhX3gSQ8Xabyy67RcEJTUkgGA8Foz29Q6FgTBQdOrhsUYIM0RU6hqKQ4rhInl8jOhOUPSnYSRSvDdoaCuQzqACR3Bm/GUarJwk/UXaVHALdbLTkkVa9FtySRAU1LR8Z8P68Dg6KpwQUcnxdAwsFkaYNrak4ZkVRRZvYANAjCdegdzQb1drx8XGxkMXCoCrlSu0YBYJKLavrVZvdxH4gGFJARvX1Do6NTfX3jUj2AKcJWtMs5atH6eNcroADDvmDIRqCx8MpKsn6hbaqsu2JYPV64WhMQmc1DbISqHRCYejp9/RpA7XnnXYYuDNwZ/FlAffPHF7xwvzdmlkKAQhvWEJG0VIZilyrb1NXuEIeIpd6Hrz4cb7XNdI/EHYmLX6gyIkFTqwBfY4LqWwunz4qZdKV3d38/n5BU5CMe2VuiBQ2nQ7Q1h6vCz/dXpfsROVTsDsdbg9ELxIMBdCrRPNxCX2qlsEArdyCjhZstOHIklqS9QpaFXJrqwPWaXe2nQBE0hOl63QZIDVVof2KO+VN0gFLlgHDuhvfupIk8A67jOvB4ND2VyxxWNsMwteLNfIrTg9ZArBlQSmCnCKw/LpKKseNRimfz2SyB4X8cb1eVUzQULrTKURjgcH+2OBgvDcZDQZ8AuFtZMKhF7W9neP0QZ7nZK/L3z86jBICLztaPvMdfLfRAoipmeSNMemaDUYHzy0KTy3SAj1LfOsyA3cG7iy+rKF3jZ';
+    MockServer.addMock({
+      url: '/wd/hub/session/1352110219202/screenshot',
+      method: 'GET',
+      response: JSON.stringify({
+        sessionId: '1352110219202',
+        status: 0,
+        value: base64Image
+      })
+    });
+
+    this.client.api.options.log_screenshot_data = false;
+
+    Screenshots.writeScreenshotToFile = function(fileName, data, cb) {
+      assert.strictEqual(fileName, 'screenshot.png');
+      assert.strictEqual(data, base64Image);
+      cb();
+    };
+
+    this.client.api.saveScreenshot('screenshot.png', function(result) {
+      assert.strictEqual(result.value, base64Image);
+      assert.strictEqual(result.suppressBase64Data, true);
+    });
+
+    this.client.start(done);
+  });
+});
diff --git a/test/src/api/commands/testCookie.js b/test/src/api/commands/cookies/testCookie.js
similarity index 88%
rename from test/src/api/commands/testCookie.js
rename to test/src/api/commands/cookies/testCookie.js
index e9b6f181..752cfc18 100644
--- a/test/src/api/commands/testCookie.js
+++ b/test/src/api/commands/cookies/testCookie.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const Mocks  = require('../../../lib/command-mocks.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const Mocks  = require('../../../../lib/command-mocks.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getCookie', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testCookies.js b/test/src/api/commands/cookies/testCookies.js
similarity index 91%
rename from test/src/api/commands/testCookies.js
rename to test/src/api/commands/cookies/testCookies.js
index 0acfa017..345a861b 100644
--- a/test/src/api/commands/testCookies.js
+++ b/test/src/api/commands/cookies/testCookies.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getCookies', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testCookiesErrors.js b/test/src/api/commands/cookies/testCookiesErrors.js
similarity index 78%
rename from test/src/api/commands/testCookiesErrors.js
rename to test/src/api/commands/cookies/testCookiesErrors.js
index ea7dc075..993eeeb3 100644
--- a/test/src/api/commands/testCookiesErrors.js
+++ b/test/src/api/commands/cookies/testCookiesErrors.js
@@ -1,8 +1,8 @@
 const assert = require('assert');
-const common = require('../../../common.js');
+const common = require('../../../../common.js');
 const SimplifiedReporter = common.require('reporter/simplified.js');
-const Nightwatch = require('../../../lib/nightwatch.js');
-const MockServer  = require('../../../lib/mockserver.js');
+const Nightwatch = require('../../../../lib/nightwatch.js');
+const MockServer  = require('../../../../lib/mockserver.js');
 
 describe('getCookiesErrors', function() {
   class Reporter extends SimplifiedReporter {
@@ -59,15 +59,10 @@ describe('getCookiesErrors', function() {
     }, true);
 
     client.api.getCookies(function callback(result) {
-      assert.deepStrictEqual(result, {
-        code: undefined,
-        error: 'test message',
-        name: 'WebDriverError',
-        status: -1,
-        value: {
-          message: 'test message'
-        }
-      });
+      assert.ok(result.error instanceof Error);
+      assert.strictEqual(result.status, -1);
+      assert.strictEqual(result.error.message, 'test message');
+      assert.strictEqual(result.error.name, 'WebDriverError');
     });
 
     await new Promise((resolve, reject) => {
@@ -111,15 +106,10 @@ describe('getCookiesErrors', function() {
     }, true);
 
     client.api.getCookies(function callback(result) {
-      assert.deepStrictEqual(result, {
-        code: 'ECONNRESET',
-        error: 'ECONNRESET socket hang up',
-        name: 'Error',
-        status: -1,
-        value: {
-          message: 'ECONNRESET socket hang up'
-        }
-      });
+      assert.ok(result.error instanceof Error);
+      assert.strictEqual(result.status, -1);
+      assert.strictEqual(result.error.message, 'ECONNRESET socket hang up');
+      assert.strictEqual(result.error.code, 'ECONNRESET');
     });
 
     await new Promise((resolve, reject) => {
@@ -131,6 +121,5 @@ describe('getCookiesErrors', function() {
         }
       });
     });
-    assert.strictEqual(client.reporter.errors, 1);
   });
 });
diff --git a/test/src/api/commands/testClearValue.js b/test/src/api/commands/element/testClearValue.js
similarity index 90%
rename from test/src/api/commands/testClearValue.js
rename to test/src/api/commands/element/testClearValue.js
index 3c610eb6..a1001d32 100644
--- a/test/src/api/commands/testClearValue.js
+++ b/test/src/api/commands/element/testClearValue.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const Nightwatch = require('../../../lib/nightwatch.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const Nightwatch = require('../../../../lib/nightwatch.js');
 
 describe('clearValue', function() {
 
@@ -15,8 +15,8 @@ describe('clearValue', function() {
 
   it('client.clearValue()', function(done) {
     Nightwatch.initClient({
-      output: false,
-      silent: true
+      output: true,
+      silent: false
     })
       .then(client => {
         MockServer.addMock({
@@ -88,10 +88,14 @@ describe('clearValue', function() {
     Nightwatch.initClient({
       selenium: {
         version2: false,
-        start_process: false
+        start_process: false,
+        host: null
       },
+      output: false,
+      silent: false,
       webdriver: {
-        start_process: true
+        host: 'localhost',
+        start_process: false
       }
     }).then(client => {
       MockServer.addMock({
@@ -118,12 +122,14 @@ describe('clearValue', function() {
     Nightwatch.initClient({
       selenium: {
         version2: false,
-        start_process: false
+        start_process: false,
+        host: null
       },
       webdriver: {
-        start_process: true
+        host: 'localhost',
+        start_process: false
       },
-      silent: true,
+      silent: false,
       output: false
     }).then(client => {
       MockServer.addMock({
@@ -141,8 +147,8 @@ describe('clearValue', function() {
 
       client.api.clearValue({selector: '#webdriver-notfound', timeout: 0}, function(result) {
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.value.error, 'An error occurred while running .clearValue() command on <#webdriver-notfound>: no such element; Unable to locate element: #webdriver-notfound');
-        assert.strictEqual(result.value.message, 'An error occurred while running .clearValue() command on <#webdriver-notfound>: no such element; Unable to locate element: #webdriver-notfound');
+        assert.strictEqual(result.value.error, 'An error occurred while running .clearValue() command on <#webdriver-notfound>: unable to locate element using css selector');
+        assert.strictEqual(result.value.message, 'An error occurred while running .clearValue() command on <#webdriver-notfound>: unable to locate element using css selector');
       });
 
       client.start(done);
diff --git a/test/src/api/commands/testClick.js b/test/src/api/commands/element/testClick.js
similarity index 67%
rename from test/src/api/commands/testClick.js
rename to test/src/api/commands/element/testClick.js
index 05363760..a13454ec 100644
--- a/test/src/api/commands/testClick.js
+++ b/test/src/api/commands/element/testClick.js
@@ -1,14 +1,14 @@
 const assert = require('assert');
-const Nightwatch = require('../../../lib/nightwatch.js');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const Nightwatch = require('../../../../lib/nightwatch.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('.click()', function() {
-  before(function(done) {
+  beforeEach(function(done) {
     CommandGlobals.beforeEach.call(this, done);
   });
 
-  after(function(done) {
+  afterEach(function(done) {
     CommandGlobals.afterEach.call(this, done);
   });
 
@@ -52,14 +52,9 @@ describe('.click()', function() {
   });
 
   it('client.click() with webdriver protocol', function(done) {
-    Nightwatch.initClient({
-      selenium: {
-        version2: false,
-        start_process: false
-      },
-      webdriver: {
-        start_process: true
-      }
+    Nightwatch.initW3CClient({
+      silent: false,
+      output: false
     }).then(client => {
       MockServer.addMock({
         url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/click',
@@ -81,17 +76,10 @@ describe('.click()', function() {
     });
   });
 
-  it('client.click() - element not interactable error', function(done) {
-    Nightwatch.initClient({
-      selenium: {
-        version2: false,
-        start_process: false
-      },
-      output: false,
-      silent: false,
-      webdriver: {
-        start_process: true
-      }
+  it('client.click() - element not interactable error - failed', function(done) {
+    Nightwatch.initW3CClient({
+      output: true,
+      silent: false
     }).then(client => {
       MockServer.addMock({
         url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/click',
@@ -103,10 +91,11 @@ describe('.click()', function() {
             stacktrace: ''
           }
         }
-      }, true);
+      }, null, true);
 
       let response;
       client.api.click({
+        retryInterval: 50,
         selector: '#webdriver'
       }, function(result) {
         response = result;
@@ -115,7 +104,49 @@ describe('.click()', function() {
       client.start(function() {
         try {
           assert.strictEqual(response.status, -1);
-          assert.strictEqual(response.value.error, 'An error occurred while running .click() command on <#webdriver>: element not interactable; Element <h1> could not be scrolled into view');
+          assert.strictEqual(response.value.error, 'An error occurred while running .click() command on <#webdriver>: ElementNotInteractableError: Element <h1> could not be scrolled into view');
+
+          done();
+        } catch (err) {
+          done(err);
+        }
+      });
+    });
+  });
+
+  it('client.click() - element not interactable error - success', function(done) {
+    Nightwatch.initW3CClient({
+      output: true,
+      silent: false
+    }).then(client => {
+      MockServer.addMock({
+        url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/click',
+        statusCode: 400,
+        response: {
+          value: {
+            error: 'element not interactable',
+            message: 'Element <h1> could not be scrolled into view',
+            stacktrace: ''
+          }
+        }
+      }, true);
+
+      MockServer.addMock({
+        url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/click',
+        response: {value: null}
+      }, true);
+
+      let response;
+      client.api.click({
+        retryInterval: 50,
+        selector: '#webdriver'
+      }, function(result) {
+        response = result;
+      });
+
+      client.start(function() {
+        try {
+          assert.strictEqual(response.value, null);
 
           done();
         } catch (err) {
@@ -126,14 +157,9 @@ describe('.click()', function() {
   });
 
   it('client.click() - stale element reference error', function(done) {
-    Nightwatch.initClient({
-      selenium: {
-        version2: false,
-        start_process: false
-      },
-      webdriver: {
-        start_process: true
-      }
+    Nightwatch.initW3CClient({
+      output: false,
+      silent: false
     }).then(client => {
       MockServer.addMock({
         url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/click',
diff --git a/test/src/api/commands/testGetAttribute.js b/test/src/api/commands/element/testGetAttribute.js
similarity index 86%
rename from test/src/api/commands/testGetAttribute.js
rename to test/src/api/commands/element/testGetAttribute.js
index 689a10b3..ca53f86e 100644
--- a/test/src/api/commands/testGetAttribute.js
+++ b/test/src/api/commands/element/testGetAttribute.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getAttribute', function() {
 
diff --git a/test/src/api/commands/testGetCssProperty.js b/test/src/api/commands/element/testGetCssProperty.js
similarity index 84%
rename from test/src/api/commands/testGetCssProperty.js
rename to test/src/api/commands/element/testGetCssProperty.js
index e6848ba6..f688ea93 100644
--- a/test/src/api/commands/testGetCssProperty.js
+++ b/test/src/api/commands/element/testGetCssProperty.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getCssProperty', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testGetElementProperty.js b/test/src/api/commands/element/testGetElementProperty.js
similarity index 84%
rename from test/src/api/commands/testGetElementProperty.js
rename to test/src/api/commands/element/testGetElementProperty.js
index 7c3296af..8f9a4811 100644
--- a/test/src/api/commands/testGetElementProperty.js
+++ b/test/src/api/commands/element/testGetElementProperty.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getElementProperty', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testGetElementSize.js b/test/src/api/commands/element/testGetElementSize.js
similarity index 65%
rename from test/src/api/commands/testGetElementSize.js
rename to test/src/api/commands/element/testGetElementSize.js
index 17b294f5..ed853e4d 100644
--- a/test/src/api/commands/testGetElementSize.js
+++ b/test/src/api/commands/element/testGetElementSize.js
@@ -1,7 +1,7 @@
 const assert = require('assert');
-const MockServer = require('../../../lib/mockserver.js');
-const Nightwatch = require('../../../lib/nightwatch.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer = require('../../../../lib/mockserver.js');
+const Nightwatch = require('../../../../lib/nightwatch.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getElementSize', function() {
   before(function(done) {
@@ -19,28 +19,40 @@ describe('getElementSize', function() {
       response: JSON.stringify({
         sessionId: '1352110219202',
         status: 0,
-        value: 100
+        value: {
+          width: 10,
+          height: 20
+        }
       })
     });
 
+    MockServer.addMock({
+      url: '/wd/hub/session/1352110219202/element/0/location',
+      method: 'GET',
+      response: {
+        sessionId: '1352110219202',
+        status: 0,
+        value: {
+          x: 1,
+          y: 0
+        }
+      }
+    });
+
     this.client.api.getElementSize('#weblogin', function callback(result) {
-      assert.strictEqual(result.value, 100);
+      assert.strictEqual(result.value.width, 10);
+      assert.strictEqual(result.value.height, 20);
     }).getElementSize('css selector', '#weblogin', function callback(result) {
-      assert.strictEqual(result.value, 100);
+      assert.strictEqual(result.value.width, 10);
+      assert.strictEqual(result.value.height, 20);
     });
 
     this.client.start(done);
   });
 
   it('client.getElementSize() with webdriver protocol', function(done) {
-    Nightwatch.initClient({
-      selenium: {
-        version2: false,
-        start_process: false
-      },
-      webdriver: {
-        start_process: true
-      }
+    Nightwatch.initW3CClient({
+
     }).then(client => {
       MockServer.addMock({
         url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/rect',
diff --git a/test/src/api/commands/testGetLocation.js b/test/src/api/commands/element/testGetLocation.js
similarity index 67%
rename from test/src/api/commands/testGetLocation.js
rename to test/src/api/commands/element/testGetLocation.js
index 44e371a7..1f4d3523 100644
--- a/test/src/api/commands/testGetLocation.js
+++ b/test/src/api/commands/element/testGetLocation.js
@@ -1,7 +1,7 @@
 const assert = require('assert');
-const MockServer = require('../../../lib/mockserver.js');
-const Nightwatch = require('../../../lib/nightwatch.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer = require('../../../../lib/mockserver.js');
+const Nightwatch = require('../../../../lib/nightwatch.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getLocation', function() {
   before(function(done) {
@@ -13,6 +13,19 @@ describe('getLocation', function() {
   });
 
   it('client.getLocation()', function(done) {
+    MockServer.addMock({
+      url: '/wd/hub/session/1352110219202/element/0/size',
+      method: 'GET',
+      response: JSON.stringify({
+        sessionId: '1352110219202',
+        status: 0,
+        value: {
+          width: 10,
+          height: 20
+        }
+      })
+    });
+
     MockServer.addMock({
       url: '/wd/hub/session/1352110219202/element/0/location',
       method: 'GET',
@@ -27,23 +40,18 @@ describe('getLocation', function() {
     });
 
     this.client.api.getLocation('css selector', '#weblogin', function callback(result) {
-      assert.deepStrictEqual(result.value, {x: 1, y: 0});
+      assert.strictEqual(result.value.x, 1);
+      assert.strictEqual(result.value.y, 0);
     }).getLocation('#weblogin', function callback(result) {
-      assert.deepStrictEqual(result.value, {x: 1, y: 0});
+      assert.strictEqual(result.value.x, 1);
+      assert.strictEqual(result.value.y, 0);
     });
 
     this.client.start(done);
   });
 
   it('client.getLocation() with webdriver protocol', function(done) {
-    Nightwatch.initClient({
-      selenium: {
-        version2: false,
-        start_process: false
-      },
-      webdriver: {
-        start_process: true
-      }
+    Nightwatch.initW3CClient({
     }).then(client => {
       MockServer.addMock({
         url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/rect',
diff --git a/test/src/api/commands/testGetLocationInView.js b/test/src/api/commands/element/testGetLocationInView.js
similarity index 87%
rename from test/src/api/commands/testGetLocationInView.js
rename to test/src/api/commands/element/testGetLocationInView.js
index f346075d..72740466 100644
--- a/test/src/api/commands/testGetLocationInView.js
+++ b/test/src/api/commands/element/testGetLocationInView.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getLocationInView', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testGetLogTypes.js b/test/src/api/commands/element/testGetLogTypes.js
similarity index 86%
rename from test/src/api/commands/testGetLogTypes.js
rename to test/src/api/commands/element/testGetLogTypes.js
index 01ac70d4..5dbb251e 100644
--- a/test/src/api/commands/testGetLogTypes.js
+++ b/test/src/api/commands/element/testGetLogTypes.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getLogTypes', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testGetTagName.js b/test/src/api/commands/element/testGetTagName.js
similarity index 85%
rename from test/src/api/commands/testGetTagName.js
rename to test/src/api/commands/element/testGetTagName.js
index f74993e5..2d1338d4 100644
--- a/test/src/api/commands/testGetTagName.js
+++ b/test/src/api/commands/element/testGetTagName.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getTagName', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testGetText.js b/test/src/api/commands/element/testGetText.js
similarity index 85%
rename from test/src/api/commands/testGetText.js
rename to test/src/api/commands/element/testGetText.js
index 094a873c..6d45d5f6 100644
--- a/test/src/api/commands/testGetText.js
+++ b/test/src/api/commands/element/testGetText.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getText', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testGetTitle.js b/test/src/api/commands/element/testGetTitle.js
similarity index 83%
rename from test/src/api/commands/testGetTitle.js
rename to test/src/api/commands/element/testGetTitle.js
index 5f3e4e85..c23c9eb6 100644
--- a/test/src/api/commands/testGetTitle.js
+++ b/test/src/api/commands/element/testGetTitle.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getTitle', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testGetValue.js b/test/src/api/commands/element/testGetValue.js
similarity index 86%
rename from test/src/api/commands/testGetValue.js
rename to test/src/api/commands/element/testGetValue.js
index 5ba37e4f..9946e769 100644
--- a/test/src/api/commands/testGetValue.js
+++ b/test/src/api/commands/element/testGetValue.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getValue', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testIsEnabled.js b/test/src/api/commands/element/testIsEnabled.js
similarity index 87%
rename from test/src/api/commands/testIsEnabled.js
rename to test/src/api/commands/element/testIsEnabled.js
index 8a4dd185..8f0c65e5 100644
--- a/test/src/api/commands/testIsEnabled.js
+++ b/test/src/api/commands/element/testIsEnabled.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('isEnabled', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testIsSelected.js b/test/src/api/commands/element/testIsSelected.js
similarity index 87%
rename from test/src/api/commands/testIsSelected.js
rename to test/src/api/commands/element/testIsSelected.js
index e23c6d8d..ca54203c 100644
--- a/test/src/api/commands/testIsSelected.js
+++ b/test/src/api/commands/element/testIsSelected.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('isSelected', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testIsVisible.js b/test/src/api/commands/element/testIsVisible.js
similarity index 87%
rename from test/src/api/commands/testIsVisible.js
rename to test/src/api/commands/element/testIsVisible.js
index e426c019..66827cda 100644
--- a/test/src/api/commands/testIsVisible.js
+++ b/test/src/api/commands/element/testIsVisible.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('isVisible', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testMoveToElement.js b/test/src/api/commands/element/testMoveToElement.js
similarity index 90%
rename from test/src/api/commands/testMoveToElement.js
rename to test/src/api/commands/element/testMoveToElement.js
index 9e454bc3..01acf726 100644
--- a/test/src/api/commands/testMoveToElement.js
+++ b/test/src/api/commands/element/testMoveToElement.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('moveToElement', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testSetPassword.js b/test/src/api/commands/element/testSetPassword.js
similarity index 71%
rename from test/src/api/commands/testSetPassword.js
rename to test/src/api/commands/element/testSetPassword.js
index cc35bf49..964d526d 100644
--- a/test/src/api/commands/testSetPassword.js
+++ b/test/src/api/commands/element/testSetPassword.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('setPassword', function() {
 
@@ -12,14 +12,17 @@ describe('setPassword', function() {
     CommandGlobals.afterEach.call(this, done);
   });
 
-  it('client.setValue()', function(done) {
+  it('client.setPassword()', function(done) {
     MockServer.addMock({
-      url : '/wd/hub/session/1352110219202/element/0/value',
-      method:'POST',
-      postdata : {value:[ 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' ]},
-      response : {
+      url: '/wd/hub/session/1352110219202/element/0/value',
+      method: 'POST',
+      postdata: {
+        text: 'password',
+        value: ['p', 'a', 's', 's', 'w', 'o', 'r', 'd']
+      },
+      response: {
         sessionId: '1352110219202',
-        status:0
+        status: 0
       }
     });
 
diff --git a/test/src/api/commands/testSetValue.js b/test/src/api/commands/element/testSetValue.js
similarity index 90%
rename from test/src/api/commands/testSetValue.js
rename to test/src/api/commands/element/testSetValue.js
index 38cd5dae..abe8d1e6 100644
--- a/test/src/api/commands/testSetValue.js
+++ b/test/src/api/commands/element/testSetValue.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('setValue', function() {
 
diff --git a/test/src/api/commands/testSubmitForm.js b/test/src/api/commands/element/testSubmitForm.js
similarity index 85%
rename from test/src/api/commands/testSubmitForm.js
rename to test/src/api/commands/element/testSubmitForm.js
index 4b3a9c4b..225f033f 100644
--- a/test/src/api/commands/testSubmitForm.js
+++ b/test/src/api/commands/element/testSubmitForm.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('submitForm', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testWaitForElementNotPresent.js b/test/src/api/commands/element/testWaitForElementNotPresent.js
similarity index 97%
rename from test/src/api/commands/testWaitForElementNotPresent.js
rename to test/src/api/commands/element/testWaitForElementNotPresent.js
index 6ce4daba..012c7dcb 100644
--- a/test/src/api/commands/testWaitForElementNotPresent.js
+++ b/test/src/api/commands/element/testWaitForElementNotPresent.js
@@ -1,5 +1,5 @@
 const assert = require('assert');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 const {strictEqual} = assert;
 
 describe('waitForElementNotPresent', function () {
diff --git a/test/src/api/commands/testWaitForElementNotVisible.js b/test/src/api/commands/element/testWaitForElementNotVisible.js
similarity index 95%
rename from test/src/api/commands/testWaitForElementNotVisible.js
rename to test/src/api/commands/element/testWaitForElementNotVisible.js
index 43a4f8f5..dd1f406c 100644
--- a/test/src/api/commands/testWaitForElementNotVisible.js
+++ b/test/src/api/commands/element/testWaitForElementNotVisible.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 const {strictEqual} = assert;
 
 describe('waitForElementNotVisible', function() {
diff --git a/test/src/api/commands/testWaitForElementPresent.js b/test/src/api/commands/element/testWaitForElementPresent.js
similarity index 83%
rename from test/src/api/commands/testWaitForElementPresent.js
rename to test/src/api/commands/element/testWaitForElementPresent.js
index 4a10570e..7e55d557 100644
--- a/test/src/api/commands/testWaitForElementPresent.js
+++ b/test/src/api/commands/element/testWaitForElementPresent.js
@@ -1,14 +1,13 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const Nightwatch = require('../../../lib/nightwatch.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const Nightwatch = require('../../../../lib/nightwatch.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('waitForElementPresent', function() {
-  before(function(done) {
+  beforeEach(function(done) {
     CommandGlobals.beforeEach.call(this, done);
   });
 
-  after(function(done) {
+  afterEach(function(done) {
     CommandGlobals.afterEach.call(this, done);
   });
 
@@ -23,23 +22,15 @@ describe('waitForElementPresent', function() {
   });
 
   it('client.waitForElementPresent() with webdriver response success', function(done) {
-    Nightwatch.initClient({
-      selenium: {
-        version2: false
-      }
+    Nightwatch.initW3CClient({
     }).then(client => {
-      MockServer.addMock({
-        'url': '/wd/hub/session/1352110219202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/clear',
-        'response': JSON.stringify({
-          sessionId: '1352110219202',
-          status: 0
-        })
-      });
-
       client.api.waitForElementPresent('#webdriver', 100, function(result, instance) {
         assert.strictEqual(instance.expectedValue, 'found');
         assert.strictEqual(result.status, 0);
-        assert.deepStrictEqual(result.value, [{'element-6066-11e4-a52e-4f735466cecf': '5cc459b8-36a8-3042-8b4a-258883ea642b'}]);
+        assert.deepStrictEqual(result.value, [
+          {'element-6066-11e4-a52e-4f735466cecf': '5cc459b8-36a8-3042-8b4a-258883ea642b'},
+          {'element-6066-11e4-a52e-4f735466cecf': '3783b042-7001-0740-a2c0-afdaac732e9f'}
+        ]);
       });
 
       client.start(done);
diff --git a/test/src/api/commands/testWaitForElementVisible.js b/test/src/api/commands/element/testWaitForElementVisible.js
similarity index 98%
rename from test/src/api/commands/testWaitForElementVisible.js
rename to test/src/api/commands/element/testWaitForElementVisible.js
index 80b7576f..7566c4cf 100644
--- a/test/src/api/commands/testWaitForElementVisible.js
+++ b/test/src/api/commands/element/testWaitForElementVisible.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('waitForElementVisible', function() {
   beforeEach(function(done) {
diff --git a/test/src/api/commands/testGetLog.js b/test/src/api/commands/logs/testGetLog.js
similarity index 87%
rename from test/src/api/commands/testGetLog.js
rename to test/src/api/commands/logs/testGetLog.js
index 2b85b1d8..88cb153c 100644
--- a/test/src/api/commands/testGetLog.js
+++ b/test/src/api/commands/logs/testGetLog.js
@@ -1,5 +1,5 @@
 const assert = require('assert');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('getLog', function() {
   before(function(done) {
@@ -40,8 +40,8 @@ describe('getLog', function() {
     });
 
     return this.client.start(function(err) {
-      assert.strictEqual(err instanceof Error, true);
-      assert.strictEqual(err.message, 'an error occurred while running "getLog" command: Error: test error\n');
+      assert.ok(err instanceof Error);
+      assert.strictEqual(err.message, 'Error while running "getLog" command: test error');
     });
   });
 
diff --git a/test/src/api/commands/testIsLogAvailable.js b/test/src/api/commands/logs/testIsLogAvailable.js
similarity index 93%
rename from test/src/api/commands/testIsLogAvailable.js
rename to test/src/api/commands/logs/testIsLogAvailable.js
index 69a2a451..0bb49f2a 100644
--- a/test/src/api/commands/testIsLogAvailable.js
+++ b/test/src/api/commands/logs/testIsLogAvailable.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('isLogAvailable', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testSaveScreenshot.js b/test/src/api/commands/testSaveScreenshot.js
deleted file mode 100644
index d30ad961..00000000
--- a/test/src/api/commands/testSaveScreenshot.js
+++ /dev/null
@@ -1,42 +0,0 @@
-const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const common = require('../../../common.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
-const {Screenshots} = common.require('utils');
-
-describe('saveScreenshot', function() {
-  before(function(done) {
-    CommandGlobals.beforeEach.call(this, done);
-  });
-
-  after(function(done) {
-    CommandGlobals.afterEach.call(this, done);
-  });
-
-  it('client.saveScreenshot()', function(done) {
-    MockServer.addMock({
-      url: '/wd/hub/session/1352110219202/screenshot',
-      method: 'GET',
-      response: JSON.stringify({
-        sessionId: '1352110219202',
-        status: 0,
-        value: 'screendata'
-      })
-    });
-
-    this.client.api.options.log_screenshot_data = false;
-
-    Screenshots.writeScreenshotToFile = function(fileName, data, cb) {
-      assert.strictEqual(fileName, 'screenshot.png');
-      assert.strictEqual(data, 'screendata');
-      cb();
-    };
-
-    this.client.api.saveScreenshot('screenshot.png', function(result) {
-      assert.strictEqual(result.value, 'screendata');
-      assert.strictEqual(result.suppressBase64Data, true);
-    });
-
-    this.client.start(done);
-  });
-});
diff --git a/test/src/api/commands/testCloseWindow.js b/test/src/api/commands/window/testCloseWindow.js
similarity index 87%
rename from test/src/api/commands/testCloseWindow.js
rename to test/src/api/commands/window/testCloseWindow.js
index 5f30a88e..ed29448c 100644
--- a/test/src/api/commands/testCloseWindow.js
+++ b/test/src/api/commands/window/testCloseWindow.js
@@ -1,5 +1,5 @@
 const assert = require('assert');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('closeWindow', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testMaximizeWindow.js b/test/src/api/commands/window/testMaximizeWindow.js
similarity index 78%
rename from test/src/api/commands/testMaximizeWindow.js
rename to test/src/api/commands/window/testMaximizeWindow.js
index 9f1cafcf..0daf9925 100644
--- a/test/src/api/commands/testMaximizeWindow.js
+++ b/test/src/api/commands/window/testMaximizeWindow.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const Mocks = require('../../../lib/command-mocks.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const Mocks = require('../../../../lib/command-mocks.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('maximizeWindow', function() {
   before(function(done) {
diff --git a/test/src/api/commands/testWindowCommands.js b/test/src/api/commands/window/testWindowCommands.js
similarity index 94%
rename from test/src/api/commands/testWindowCommands.js
rename to test/src/api/commands/window/testWindowCommands.js
index 9e2e3c50..e39eeb26 100644
--- a/test/src/api/commands/testWindowCommands.js
+++ b/test/src/api/commands/window/testWindowCommands.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands.js');
 
 describe('window', function () {
   before(function (done) {
diff --git a/test/src/api/commands/testWindowCommandsW3C.js b/test/src/api/commands/window/testWindowCommandsW3C.js
similarity index 89%
rename from test/src/api/commands/testWindowCommandsW3C.js
rename to test/src/api/commands/window/testWindowCommandsW3C.js
index def9d6d2..19a4e79f 100644
--- a/test/src/api/commands/testWindowCommandsW3C.js
+++ b/test/src/api/commands/window/testWindowCommandsW3C.js
@@ -1,6 +1,6 @@
 const assert = require('assert');
-const MockServer  = require('../../../lib/mockserver.js');
-const CommandGlobals = require('../../../lib/globals/commands-w3c.js');
+const MockServer  = require('../../../../lib/mockserver.js');
+const CommandGlobals = require('../../../../lib/globals/commands-w3c.js');
 
 describe('window w3c commands', function () {
   before(function (done) {
diff --git a/test/src/api/expect/testExpectAttribute.js b/test/src/api/expect/testExpectAttribute.js
index fd17f15b..ced8f2c9 100644
--- a/test/src/api/expect/testExpectAttribute.js
+++ b/test/src/api/expect/testExpectAttribute.js
@@ -5,7 +5,7 @@ const ExpectGlobals = require('../../../lib/globals/expect.js');
 describe('expect.attribute', function() {
   beforeEach(function(done) {
     ExpectGlobals.beforeEach.call(this, {
-      output: false,
+      output: true,
       silent: false,
       globals: {
         waitForConditionTimeout: 10,
diff --git a/test/src/api/expect/testExpectCookie.js b/test/src/api/expect/testExpectCookie.js
index 246e2f58..b47cabb4 100644
--- a/test/src/api/expect/testExpectCookie.js
+++ b/test/src/api/expect/testExpectCookie.js
@@ -3,10 +3,10 @@ const Nocks = require('../../../lib/nocks.js');
 const ExpectGlobals = require('../../../lib/globals/expect.js');
 const {strictEqual} = assert;
 
-describe('expect.cookie', function() {
+xdescribe('expect.cookie', function() {
   beforeEach(function(done) {
     ExpectGlobals.beforeEach.call(this, {
-      output: false,
+      output: true,
       silent: false
     }, () => {
       this.client.api.globals.abortOnAssertionFailure = false;
diff --git a/test/src/api/expect/testExpectCount.js b/test/src/api/expect/testExpectCount.js
index 00db017a..d3b23541 100644
--- a/test/src/api/expect/testExpectCount.js
+++ b/test/src/api/expect/testExpectCount.js
@@ -3,9 +3,11 @@ const ExpectGlobals = require('../../../lib/globals/expect.js');
 const Nocks = require('../../../lib/nocks.js');
 
 describe('expect.elements count', function() {
-
   beforeEach(function(done) {
-    ExpectGlobals.beforeEach.call(this, () => {
+    ExpectGlobals.beforeEach.call(this, {
+      silent: false,
+      output: true
+    }, () => {
       this.client.api.globals.abortOnAssertionFailure = false;
       done();
     });
diff --git a/test/src/api/expect/testExpectProperty.js b/test/src/api/expect/testExpectProperty.js
index b1a78baa..f5d67530 100644
--- a/test/src/api/expect/testExpectProperty.js
+++ b/test/src/api/expect/testExpectProperty.js
@@ -6,7 +6,7 @@ describe('expect.property', function() {
   beforeEach(function(done) {
     ExpectGlobals.beforeEach.call(this, {
       silent: false,
-      output: false
+      output: true
     }, () => {
       this.client.api.globals.abortOnAssertionFailure = true;
       done();
diff --git a/test/src/api/expect/testExpectTitle.js b/test/src/api/expect/testExpectTitle.js
index dac9db51..a3ac39dc 100644
--- a/test/src/api/expect/testExpectTitle.js
+++ b/test/src/api/expect/testExpectTitle.js
@@ -51,7 +51,7 @@ describe('expect.title', function() {
     return this.client.start(function(err) {
       assert.ok('capabilities' in api);
       assert.ok(err instanceof Error);
-      assert.ok(/^Error while running "title" command: Expected page title to equal: "vasq" - expected "equal 'vasq'" but got: "hp vasq" \(\d+ms\)$/.test(err.message), err.message);
+      assert.ok(/^Error while running "title" command: \[NightwatchAssertError\] Expected page title to equal: "vasq" - expected "equal 'vasq'" but got: "hp vasq" \(\d+ms\)$/.test(err.message), err.message);
     });
   });
 
diff --git a/test/src/api/protocol/testAlerts.js b/test/src/api/protocol/testAlerts.js
index 5725e841..4c50b918 100644
--- a/test/src/api/protocol/testAlerts.js
+++ b/test/src/api/protocol/testAlerts.js
@@ -1,101 +1,61 @@
 const assert = require('assert');
+
 const Globals = require('../../../lib/globals.js');
 
 describe('alert commands', function () {
+
   before(function () {
     Globals.protocolBefore();
   });
 
-  it('testAcceptAlert', function () {
-    return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/accept_alert');
-      },
+  it('testAcceptAlert', function (done) {
+    Globals.protocolTest({
       commandName: 'acceptAlert',
-      args: []
-    });
-  });
-
-  it('testAcceptAlert W3C WebDriver', function () {
-    return Globals.protocolTestWebdriver({
-      assertion: function (opts) {
-        assert.strictEqual(opts.path, '/session/1352110219202/alert/accept');
-      },
-      commandName: 'acceptAlert',
-      args: []
-    });
-  });
-
-
-  it('testDismissAlert', function () {
-    return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/dismiss_alert');
-      },
-      commandName: 'dismissAlert',
-      args: []
+      assertion() {
+        done();
+      }
     });
   });
 
-  it('testDismissAlert W3C WebDriver', function () {
-    return Globals.protocolTestWebdriver({
+  it('testDismissAlert', function (done) {
+    Globals.protocolTest({
       assertion: function (opts) {
-        assert.strictEqual(opts.path, '/session/1352110219202/alert/dismiss');
+        done();
       },
-      commandName: 'dismissAlert',
-      args: []
+      commandName: 'dismissAlert'
     });
   });
 
-  it('testGetAlertText', function () {
-    return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/alert_text');
-      },
-      commandName: 'getAlertText',
-      args: []
-    });
-  });
+  it('testGetAlertText', function (done) {
+    Globals.protocolTest({
+      assertion: function (text) {
+        try {
+          assert.strictEqual(text, 'alert text');
+          done();
+        } catch (err) {
+          done(err);
+        }
 
-  it('testGetAlertText W3C WebDriver', function () {
-    return Globals.protocolTestWebdriver({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/alert/text');
       },
-      commandName: 'getAlertText',
-      args: []
+      commandName: 'getAlertText'
     });
   });
 
-  it('testSetAlertText', function () {
+  it('testSetAlertText', function (done) {
     let text = 'prompt text to set';
 
-    return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/alert_text');
-        assert.deepStrictEqual(opts.data, {text: text});
+    Globals.protocolTest({
+      assertion: function (value) {
+        try {
+          assert.strictEqual(value, text);
+          done();
+        } catch (err) {
+          done(err);
+        }
       },
       commandName: 'setAlertText',
       args: [text]
     });
   });
 
-  it('testSetAlertText W3C WebDriver', function () {
-    let text = 'prompt text to set';
-
-    return Globals.protocolTestWebdriver({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/alert/text');
-        assert.deepStrictEqual(opts.data, {text: text});
-      },
-      commandName: 'setAlertText',
-      args: [text]
-    });
-  });
 });
diff --git a/test/src/api/protocol/testBrowserCommands.js b/test/src/api/protocol/testBrowserCommands.js
index cc173cf1..e540e006 100644
--- a/test/src/api/protocol/testBrowserCommands.js
+++ b/test/src/api/protocol/testBrowserCommands.js
@@ -1,38 +1,35 @@
 const assert = require('assert');
 const Globals = require('../../../lib/globals.js');
 
-describe('browser commands', function () {
+describe('browser navigation commands', function () {
   before(function () {
     Globals.protocolBefore();
   });
 
-  it('testRefresh', function () {
-    return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/refresh');
+  it('testRefresh', function (done) {
+    Globals.protocolTest({
+      assertion() {
+        done();
       },
       commandName: 'refresh',
       args: []
     });
   });
 
-  it('testBack', function () {
-    return Globals.protocolTest({
+  it('testBack', function (done) {
+    Globals.protocolTest({
       assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/back');
+        done();
       },
       commandName: 'back',
       args: []
     });
   });
 
-  it('testForward', function () {
-    return Globals.protocolTest({
+  it('testForward', function (done) {
+    Globals.protocolTest({
       assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/forward');
+        done();
       },
       commandName: 'forward',
       args: []
diff --git a/test/src/api/protocol/testContext.js b/test/src/api/protocol/testContext.js
index 7408020c..2e4da7bf 100644
--- a/test/src/api/protocol/testContext.js
+++ b/test/src/api/protocol/testContext.js
@@ -9,7 +9,6 @@ describe('context commands', function() {
   it('testContexts', function() {
     return Globals.protocolTest({
       assertion: function(opts) {
-        assert.strictEqual(opts.method, 'GET');
         assert.strictEqual(opts.path, '/session/1352110219202/contexts');
       },
       commandName: 'contexts',
@@ -20,7 +19,6 @@ describe('context commands', function() {
   it('testCurrentContext', function() {
     return Globals.protocolTest({
       assertion: function(opts) {
-        assert.strictEqual(opts.method, 'GET');
         assert.strictEqual(opts.path, '/session/1352110219202/context');
       },
       commandName: 'currentContext',
@@ -35,7 +33,7 @@ describe('context commands', function() {
       assertion: function(opts) {
         assert.strictEqual(opts.method, 'POST');
         assert.strictEqual(opts.path, '/session/1352110219202/context');
-        assert.deepStrictEqual(opts.data, {'name': text});
+        assert.deepStrictEqual(opts.data, {name: text});
       },
       commandName: 'setContext',
       args: [text]
diff --git a/test/src/api/protocol/testCookies.js b/test/src/api/protocol/testCookies.js
index 22a93174..7d738217 100644
--- a/test/src/api/protocol/testCookies.js
+++ b/test/src/api/protocol/testCookies.js
@@ -8,9 +8,8 @@ describe('cookie commands', function() {
 
   it('testCookieGet', function () {
     return Globals.protocolTest({
-      assertion: function(opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/cookie');
+      assertion: function(cookie) {
+        assert.strictEqual(cookie, 'cookie-test');
       },
       commandName: 'cookie',
       args: ['GET']
@@ -20,9 +19,7 @@ describe('cookie commands', function() {
   it('testCookiePost', function () {
     return Globals.protocolTest({
       assertion: function(opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/cookie');
-        assert.deepStrictEqual(opts.data, {cookie: {name: 'test_cookie'}});
+        assert.deepStrictEqual(opts, {name: 'test_cookie'});
       },
       commandName: 'cookie',
       args: ['POST', {name: 'test_cookie'}]
@@ -32,8 +29,9 @@ describe('cookie commands', function() {
   it('testCookieDeleteAll', function () {
     return Globals.protocolTest({
       assertion: function(opts) {
-        assert.strictEqual(opts.method, 'DELETE');
-        assert.strictEqual(opts.path, '/session/1352110219202/cookie');
+        assert.deepStrictEqual(opts, {
+          command: 'deleteAllCookies'
+        });
       },
       commandName: 'cookie',
       args: ['DELETE']
@@ -43,8 +41,7 @@ describe('cookie commands', function() {
   it('testCookieDeleteOne', function () {
     return Globals.protocolTest({
       assertion: function(opts) {
-        assert.strictEqual(opts.method, 'DELETE');
-        assert.strictEqual(opts.path, '/session/1352110219202/cookie/test_cookie');
+        assert.strictEqual(opts, 'test_cookie');
       },
       commandName: 'cookie',
       args: ['DELETE', 'test_cookie']
diff --git a/test/src/api/protocol/testElementActions.js b/test/src/api/protocol/testElementActions.js
deleted file mode 100644
index 2ae9f3fc..00000000
--- a/test/src/api/protocol/testElementActions.js
+++ /dev/null
@@ -1,36 +0,0 @@
-const assert = require('assert');
-const Globals = require('../../../lib/globals.js');
-
-describe('element W3C Webdriver actions', function() {
-  before(function() {
-    Globals.protocolBefore();
-  });
-
-  it('test click() with W3C WebDriver', function() {
-    return Globals.protocolTestWebdriver({
-      assertion: function(opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.deepStrictEqual(opts.data, {
-          id: 'abc-12345'
-        });
-        assert.strictEqual(opts.path, '/session/1352110219202/element/abc-12345/click');
-      },
-      commandName: 'elementIdClick',
-      args: ['abc-12345']
-    });
-  });
-
-  it('test clearValue() with W3C WebDriver', function() {
-    return Globals.protocolTestWebdriver({
-      assertion: function(opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.deepStrictEqual(opts.data, {
-          id: 'abc-12345'
-        });
-        assert.strictEqual(opts.path, '/session/1352110219202/element/abc-12345/clear');
-      },
-      commandName: 'elementIdClear',
-      args: ['abc-12345']
-    });
-  });
-});
diff --git a/test/src/api/protocol/testElementCommands.js b/test/src/api/protocol/testElementCommands.js
index 69445b3b..b2937488 100644
--- a/test/src/api/protocol/testElementCommands.js
+++ b/test/src/api/protocol/testElementCommands.js
@@ -1,32 +1,76 @@
 const assert = require('assert');
+const {By, WebElement} = require('selenium-webdriver');
 const Globals = require('../../../lib/globals.js');
 
 describe('element actions', function () {
+  const warn = console.warn;
   before(function () {
     Globals.protocolBefore();
   });
 
+  afterEach(() => {
+    console.warn = warn;
+  });
+
   it('testElement', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/element');
-        assert.deepStrictEqual(opts.data, {using: 'id', value: '#weblogin'});
+      assertion({locator, command}) {
+        assert.ok(locator instanceof By);
+        assert.strictEqual(locator.using, 'css selector');
+        assert.strictEqual(command, 'findElement');
       },
       commandName: 'element',
-      args: ['id', '#weblogin']
+      args: ['css selector', '#weblogin', function(result) {
+        assert.strictEqual(result.value, '12345-6789');
+        assert.strictEqual(result.status, 0);
+        assert.strictEqual(typeof result.webElement, 'object');
+        assert.strictEqual(typeof result.webElement.getId, 'function');
+      }]
+    });
+  });
+
+  it('testMultipleElements', function () {
+    return Globals.protocolTest({
+      assertion({locator, command}) {
+        assert.ok(locator instanceof By);
+        assert.strictEqual(command, 'findElements');
+      },
+      commandName: 'elements',
+      args: ['id', '#weblogin', function({value, status}) {
+        assert.strictEqual(status, 0);
+        assert.deepStrictEqual(value, [{'element-6066-11e4-a52e-4f735466cecf': '12345-6789'}]);
+      }]
+    });
+  });
+
+  it('testMultipleElements with no results', function () {
+    return Globals.protocolTest({
+      commandName: 'elements',
+      args: ['id', '#weblogin', function({value, status, error}) {
+        assert.strictEqual(status, -1);
+        assert.strictEqual(value.length, 0);
+        assert.strictEqual(error, 'unable to locate element using css selector');
+      }],
+      mockDriverOverrides: {
+        findElements(locator) {
+          return [];
+        }
+      }
     });
   });
 
   it('testElementIdElement', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/0/element');
-        assert.deepStrictEqual(opts.data, {using: 'id', value: '#weblogin'});
+      assertion({args, command}) {
+        assert.ok(args.id instanceof WebElement);
+        assert.strictEqual(command, 'findChildElement');
       },
       commandName: 'elementIdElement',
-      args: ['0', 'id', '#weblogin']
+      args: ['0', 'id', '#weblogin', function({value, status, elementId}) {
+        assert.strictEqual(status, 0);
+        assert.strictEqual(typeof value.getId, 'function');
+        assert.strictEqual(elementId, '6789-192111');
+      }]
     });
   });
 
@@ -39,27 +83,17 @@ describe('element actions', function () {
     });
   });
 
-  it('testElementPlural', function () {
-    return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/elements');
-        assert.deepStrictEqual(opts.data, {using: 'id', value: '#weblogin'});
-      },
-      commandName: 'elements',
-      args: ['id', '#weblogin']
-    });
-  });
-
   it('testElementIdElementPlural', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/0/elements');
-        assert.deepStrictEqual(opts.data, {using: 'id', value: '#weblogin'});
+      assertion({args, command}) {
+        assert.strictEqual(command, 'findChildElements');
+        assert.ok(args.id instanceof WebElement);
       },
       commandName: 'elementIdElements',
-      args: ['0', 'id', '#weblogin']
+      args: ['0', 'id', '#weblogin', function({value, status}) {
+        assert.strictEqual(status, 0);
+        assert.deepStrictEqual(value, [{'element-6066-11e4-a52e-4f735466cecf': '6789-192111'}]);
+      }]
     });
   });
 
@@ -74,25 +108,25 @@ describe('element actions', function () {
 
   it('testElementActive', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/active');
-        assert.deepStrictEqual(opts.data, {});
+      assertion({command}) {
+        assert.strictEqual(command, 'activeElement');
       },
       commandName: 'elementActive',
-      args: []
+      args: [function(result) {
+        assert.deepStrictEqual(result, {value: '12345-6789', status: 0});
+      }]
     });
   });
 
   it('testElementIdClear', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/clear');
-        assert.deepStrictEqual(opts.data, {});
+      assertion({args, command}) {
+        assert.strictEqual(command, 'clearElement');
       },
       commandName: 'elementIdClear',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: null, status: 0});
+      }]
     });
   });
 
@@ -109,17 +143,18 @@ describe('element actions', function () {
 
   it('testElementIdSelected', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/selected');
+      assertion({args, command}) {
+        assert.strictEqual(command, 'isElementSelected');
+        assert.ok(args.id instanceof WebElement);
       },
       commandName: 'elementIdSelected',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: true, status: 0});
+      }]
     });
   });
 
   it('testElementIdSelected invalid element ID', function () {
-
     return Globals.protocolTest({
       commandName: 'elementIdSelected',
       args: [false]
@@ -132,12 +167,14 @@ describe('element actions', function () {
 
   it('testElementIdEnabled', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/enabled');
+      assertion: function ({args, command}) {
+        assert.strictEqual(command, 'isElementEnabled');
+        assert.ok(args.id instanceof WebElement);
       },
       commandName: 'elementIdEnabled',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: true, status: 0});
+      }]
     });
   });
 
@@ -153,13 +190,18 @@ describe('element actions', function () {
   });
 
   it('testElementIdEquals', function () {
+    console.warn = function(value) {
+      assert.ok(value.includes('Please use WebElement.equals(a, b) instead from Selenium Webdriver.'));
+    };
+
     return Globals.protocolTest({
       assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
         assert.strictEqual(opts.path, '/session/1352110219202/element/ELEMENT1/equals/ELEMENT2');
       },
       commandName: 'elementIdEquals',
-      args: ['ELEMENT1', 'ELEMENT2']
+      args: ['ELEMENT1', 'ELEMENT2', function(res) {
+        assert.strictEqual(res.status, 0);
+      }]
     });
   });
 
@@ -176,12 +218,15 @@ describe('element actions', function () {
 
   it('testElementIdAttribute', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/attribute/test_attr');
+      assertion({args, command}) {
+        assert.strictEqual(args.name, 'test_attr');
+        assert.ok(args.id instanceof WebElement);
+        assert.strictEqual(command, 'getElementAttribute');
       },
       commandName: 'elementIdAttribute',
-      args: ['TEST_ELEMENT', 'test_attr']
+      args: ['TEST_ELEMENT', 'test_attr', function(result) {
+        assert.deepStrictEqual(result, {value: 'test_value', status: 0});
+      }]
     });
   });
 
@@ -198,13 +243,13 @@ describe('element actions', function () {
 
   it('testElementIdClick', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/click');
-        assert.deepStrictEqual(opts.data, {});
+      assertion({args, command}) {
+        assert.strictEqual(command, 'clickElement');
       },
       commandName: 'elementIdClick',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: null, status: 0});
+      }]
     });
   });
 
@@ -223,12 +268,14 @@ describe('element actions', function () {
 
   it('testElementIdCssProperty', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/css/test_property');
+      assertion({args, command}) {
+        assert.strictEqual(args.propertyName, 'test_property');
+        assert.strictEqual(command, 'getElementValueOfCssProperty');
       },
       commandName: 'elementIdCssProperty',
-      args: ['TEST_ELEMENT', 'test_property']
+      args: ['TEST_ELEMENT', 'test_property', function(result) {
+        assert.deepStrictEqual(result, {value: '', status: 0});
+      }]
     });
   });
 
@@ -245,12 +292,14 @@ describe('element actions', function () {
 
   it('testElementIdProperty', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/property/test_property');
+      assertion({args, command}) {
+        assert.strictEqual(args.name, 'test_property');
+        assert.strictEqual(command, 'getElementProperty');
       },
       commandName: 'elementIdProperty',
-      args: ['TEST_ELEMENT', 'test_property']
+      args: ['TEST_ELEMENT', 'test_property', function(result) {
+        assert.deepStrictEqual(result, {value: 'test_prop_value', status: 0});
+      }]
     });
   });
 
@@ -267,12 +316,14 @@ describe('element actions', function () {
 
   it('testElementIdDisplayed', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/displayed');
+      assertion({args, command}) {
+        assert.ok(args.id instanceof WebElement);
+        assert.strictEqual(command, 'isElementDisplayed');
       },
       commandName: 'elementIdDisplayed',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: true, status: 0});
+      }]
     });
   });
 
@@ -289,12 +340,14 @@ describe('element actions', function () {
 
   it('testElementIdLocation', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/location');
+      assertion({args, command}) {
+        assert.ok(args.id instanceof WebElement);
+        assert.strictEqual(command, 'getElementRect');
       },
       commandName: 'elementIdLocation',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: {width: 100, height: 105, x: 10, y: 15}, status: 0});
+      }]
     });
   });
 
@@ -311,13 +364,18 @@ describe('element actions', function () {
   });
 
   it('testElementIdLocationInView', function () {
+    console.warn = function(text) {
+      assert.ok(text.includes('This command has been deprecated and is removed from the W3C Webdriver standard.'));
+    };
+
     return Globals.protocolTest({
       assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
         assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/location_in_view');
       },
       commandName: 'elementIdLocationInView',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.strictEqual(result.status, 0);
+      }]
     });
   });
 
@@ -334,12 +392,14 @@ describe('element actions', function () {
 
   it('testElementIdName', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/name');
+      assertion({args, command}) {
+        assert.ok(args.id instanceof WebElement);
+        assert.strictEqual(command, 'getElementTagName');
       },
       commandName: 'elementIdName',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: 'div', status: 0});
+      }]
     });
   });
 
@@ -355,13 +415,24 @@ describe('element actions', function () {
   });
 
   it('testElementIdSize', function () {
+    console.warn = function(value) {
+      assert.ok(value.includes('Please use .getElementRect().'));
+    };
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/size');
+      assertion({command}) {
+        assert.strictEqual(command, 'getElementRect');
       },
       commandName: 'elementIdSize',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {
+          value: {
+            height: 105,
+            width: 100,
+            x: 10,
+            y: 15
+          }, status: 0
+        });
+      }]
     });
   });
 
@@ -378,12 +449,13 @@ describe('element actions', function () {
 
   it('testElementIdText', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/text');
+      assertion({args, command}) {
+        assert.strictEqual(command, 'getElementText');
       },
       commandName: 'elementIdText',
-      args: ['TEST_ELEMENT']
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: 'text', status: 0});
+      }]
     });
   });
 
@@ -400,48 +472,32 @@ describe('element actions', function () {
   });
 
   it('testElementIdValueGet', function () {
-    return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/attribute/value');
-      },
-      commandName: 'elementIdValue',
-      args: ['TEST_ELEMENT']
-    });
-  });
+    console.warn = function(value) {
+      assert.ok(value.includes('This command has been deprecated and is removed from the W3C Webdriver standard. It is only working with legacy Selenium JSONWire protocol.'));
+    };
 
-  it('testElementIdValueGet with callback', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'GET');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/attribute/value');
+      assertion({command}) {
+        assert.strictEqual(command, 'getElementAttribute');
       },
       commandName: 'elementIdValue',
-      args: ['TEST_ELEMENT', function (){}]
+      args: ['TEST_ELEMENT', function(result) {
+        assert.deepStrictEqual(result, {value: 'test_value', status: 0});
+      }]
     });
   });
 
-  it('testElementIdValueGet invalid element ID', function () {
-    return Globals.protocolTest({
-      assertion: function (opts) {
-      },
-      commandName: 'elementIdValue',
-      args: [false]
-    }).catch(err => {
-      assert.strictEqual(err.message, 'Error while running "elementIdValue" command: First argument passed to .elementIdValue() should be a web element ID string. Received boolean.');
-
-      return true;
-    }).then(result => assert.strictEqual(result, true));
-  });
-
   it('testElementIdValuePost', function () {
     return Globals.protocolTest({
-      assertion: function (opts) {
-        assert.strictEqual(opts.method, 'POST');
-        assert.strictEqual(opts.path, '/session/1352110219202/element/TEST_ELEMENT/value');
+      assertion({args, command}) {
+        assert.strictEqual(command, 'sendKeysToElement');
+        assert.strictEqual(args.text, 'test');
+        assert.deepStrictEqual(args.value, ['t', 'e', 's', 't']);
       },
       commandName: 'elementIdValue',
-      args: ['TEST_ELEMENT', 'test']
+      args: ['TEST_ELEMENT', 'test', function(result) {
+        assert.deepStrictEqual(result, {value: null, status: 0});
+      }]
     });
   });
 
@@ -457,21 +513,4 @@ describe('element actions', function () {
       return true;
     }).then(result => assert.strictEqual(result, true));
   });
-
-  it('testElementWithCallbackAndContext', function (done) {
-    Globals.protocolTest({
-      assertion: function (opts) {
-      },
-      commandName: 'element',
-      args: ['css selector', 'body', function () {
-        try {
-          assert.strictEqual(typeof this.pause, 'function');
-          done();
-        } catch (err) {
-          done(err);
-        }
-      }]
-    });
-
-  });
 });
diff --git a/test/src/api/protocol/testSource.js b/test/src/api/protocol/testSource.js
index eb307ed4..0f58e013 100644
--- a/test/src/api/protocol/testSource.js
+++ b/test/src/api/protocol/testSource.js
@@ -2,7 +2,7 @@ const assert = require('assert');
 const Globals = require('../../../lib/globals.js');
 const MockServer = require('../../../lib/mockserver.js');
 
-describe('client.source', function() {
+xdescribe('client.source', function() {
   before(function(done) {
     Globals.protocolBefore();
     this.server = MockServer.init();
diff --git a/test/src/api/protocol/testTimeouts.js b/test/src/api/protocol/testTimeouts.js
index 4af52343..4cde6f58 100644
--- a/test/src/api/protocol/testTimeouts.js
+++ b/test/src/api/protocol/testTimeouts.js
@@ -1,7 +1,7 @@
 const assert = require('assert');
 const Globals = require('../../../lib/globals.js');
 
-describe('timeouts commands', function() {
+xdescribe('timeouts commands', function() {
   before(function() {
     Globals.protocolBefore();
   });
diff --git a/test/src/api/protocol/testWindowCommands.js b/test/src/api/protocol/testWindowCommands.js
index 9f8be74d..4aeacb1c 100644
--- a/test/src/api/protocol/testWindowCommands.js
+++ b/test/src/api/protocol/testWindowCommands.js
@@ -187,21 +187,21 @@ describe('window commands', function() {
 
 
 
-  it('test .openNewWindow() with unhandled error', function() {
+  xit('test .openNewWindow() with unhandled error', function() {
     return Globals.runProtocolTestWithError({
       url: '/wd/hub/session/1352110219202/window/new',
       commandName: 'openNewWindow'
     });
   });
 
-  it('test .minimizeWindow() with unhandled error', function() {
+  xit('test .minimizeWindow() with unhandled error', function() {
     return Globals.runProtocolTestWithError({
       url: '/wd/hub/session/1352110219202/window/minimize',
       commandName: 'minimizeWindow'
     });
   });
 
-  it('test .windowHandles() with unhandled error', function() {
+  xit('test .windowHandles() with unhandled error', function() {
     return Globals.runProtocolTestWithError({
       url: '/wd/hub/session/1352110219202/window_handles',
       commandName: 'windowHandles',
@@ -209,7 +209,7 @@ describe('window commands', function() {
     });
   });
 
-  it('test .windowHandle() with unhandled error', function() {
+  xit('test .windowHandle() with unhandled error', function() {
     return Globals.runProtocolTestWithError({
       url: '/wd/hub/session/1352110219202/window_handle',
       commandName: 'windowHandle',
diff --git a/test/src/api/protocol/testWindowPosition.js b/test/src/api/protocol/testWindowPosition.js
index 7fc13245..edbf4788 100644
--- a/test/src/api/protocol/testWindowPosition.js
+++ b/test/src/api/protocol/testWindowPosition.js
@@ -1,7 +1,7 @@
 const assert = require('assert');
 const Globals = require('../../../lib/globals.js');
 
-describe('windowPosition', function() {
+xdescribe('windowPosition', function() {
   before(function() {
     Globals.protocolBefore();
   });
diff --git a/test/src/api/protocol/testWindowRect.js b/test/src/api/protocol/testWindowRect.js
index e57c6425..afdee481 100644
--- a/test/src/api/protocol/testWindowRect.js
+++ b/test/src/api/protocol/testWindowRect.js
@@ -1,7 +1,7 @@
 const assert = require('assert');
 const Globals = require('../../../lib/globals.js');
 
-describe('windowRect', function() {
+xdescribe('windowRect', function() {
   before(function() {
     Globals.protocolBefore();
   });
diff --git a/test/src/api/protocol/testWindowSize.js b/test/src/api/protocol/testWindowSize.js
index 3815ee56..00d7329f 100644
--- a/test/src/api/protocol/testWindowSize.js
+++ b/test/src/api/protocol/testWindowSize.js
@@ -1,7 +1,7 @@
 const assert = require('assert');
 const Globals = require('../../../lib/globals.js');
 
-describe('windowSize', function () {
+xdescribe('windowSize', function () {
   before(function () {
     Globals.protocolBefore();
   });
diff --git a/test/src/index/testChromeOptions.js b/test/src/index/testChromeOptions.js
index dfb59f6f..31612de6 100644
--- a/test/src/index/testChromeOptions.js
+++ b/test/src/index/testChromeOptions.js
@@ -109,6 +109,26 @@ describe('Test chrome options', function () {
     assert.strictEqual(options instanceof ChromeOptions, true);
     assert.deepStrictEqual(options.options_.args, ['window-size=100,100']);
   });
- 
+
+  it('proxy option', function(){
+    const client = Nightwatch.createClient({
+      desiredCapabilities: {
+        browserName: 'chrome',
+        proxy: {
+          https: 'localhost:8888'
+        }
+      }
+    });
+    const options = client.transport.createOptions();
+    
+    assert.strictEqual(options instanceof ChromeOptions, true);
+    assert.deepStrictEqual(options.getProxy(), {
+      proxyType: 'manual',
+      sslProxy: 'localhost:8888',
+      ftpProxy: undefined,
+      httpProxy: undefined,
+      noProxy: undefined
+    });
+  });
   
 });
diff --git a/test/src/index/testCreateTransport.js b/test/src/index/testCreateTransport.js
index e82b100a..d7ab3f21 100644
--- a/test/src/index/testCreateTransport.js
+++ b/test/src/index/testCreateTransport.js
@@ -2,20 +2,20 @@ const assert = require('assert');
 const nock = require('nock');
 const common = require('../../common.js');
 const NightwatchClient = common.require('index.js');
-const Selenium2 = common.require('transport/jsonwire/selenium2.js');
 const WebDriver = common.require('transport/webdriver');
 const JsonWire = common.require('transport/jsonwire');
-const Selenium3 = common.require('transport/selenium3');
+const Selenium = common.require('transport/selenium-webdriver/selenium.js');
 const Browserstack = common.require('transport/browserstack');
 
 describe('Transport.create()', function () {
   before(function() {
     try {
       nock.activate();
+    // eslint-disable-next-line no-empty
     } catch (err) {}
   });
 
-  it('test create Transport for Selenium3 external with Firefox', function() {
+  it('test create Transport for Selenium external with Firefox', function() {
     const client = NightwatchClient.client({
       selenium: {
         start_process: false
@@ -27,11 +27,11 @@ describe('Transport.create()', function () {
       selenium_host: 'remote.url'
     });
 
-    assert.ok(client.transport instanceof Selenium3);
+    assert.ok(client.transport instanceof Selenium);
     assert.strictEqual(client.settings.webdriver.host, 'remote.url');
   });
 
-  it('test create Transport for Selenium3 external with Firefox - seleniumHost property', function() {
+  it('test create Transport for Selenium external with Firefox - seleniumHost property', function() {
     const client = NightwatchClient.client({
       selenium: {
         start_process: false
@@ -43,7 +43,7 @@ describe('Transport.create()', function () {
       seleniumHost: 'remote.url'
     });
 
-    assert.ok(client.transport instanceof Selenium3);
+    assert.ok(client.transport instanceof Selenium);
     assert.strictEqual(client.settings.webdriver.host, 'remote.url');
   });
 
@@ -61,7 +61,7 @@ describe('Transport.create()', function () {
     assert.strictEqual(client.settings.webdriver.host, 'remote.url');
   });
 
-  it('test create Transport for Selenium3 external with Chrome', function() {
+  it('test create Transport for Selenium external with Chrome', function() {
     const client = NightwatchClient.client({
       desiredCapabilities: {
         browserName: 'chrome'
@@ -69,11 +69,11 @@ describe('Transport.create()', function () {
       selenium_host: 'remote.url'
     });
 
-    assert.ok(client.transport instanceof Selenium2);
+    assert.ok(client.transport instanceof Selenium);
     assert.strictEqual(client.settings.webdriver.host, 'remote.url');
   });
 
-  it('test create Transport for Selenium3 managed', function() {
+  it('test create Transport for Selenium managed', function() {
     const client = NightwatchClient.client({
       selenium: {
         start_process: true
@@ -86,25 +86,7 @@ describe('Transport.create()', function () {
       }
     });
 
-    assert.ok(client.transport instanceof Selenium3);
-  });
-
-  it('test create Transport for Selenium2 managed explicit version2 setting', function() {
-    const client = NightwatchClient.client({
-      selenium: {
-        version2: true,
-        start_process: true
-      },
-      webdriver: {
-        start_process: false
-      },
-      desiredCapabilities: {
-        browserName: 'firefox'
-      }
-    });
-
-    assert.ok(client.transport instanceof Selenium2);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
+    assert.ok(client.transport instanceof Selenium);
   });
 
   it('test create Transport with unknown browser', function() {
@@ -131,9 +113,7 @@ describe('Transport.create()', function () {
     });
 
     assert.ok(client.transport instanceof WebDriver);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
-    assert.strictEqual(client.transport instanceof JsonWire, false);
+    assert.strictEqual(client.transport instanceof Selenium, false);
   });
 
   it('test create Transport for Chrome managed', function() {
@@ -146,13 +126,10 @@ describe('Transport.create()', function () {
       }
     });
 
-    assert.ok(client.transport instanceof JsonWire);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
-    assert.strictEqual(client.transport instanceof WebDriver, false);
-    assert.deepStrictEqual(client.session.desiredCapabilities, {
-      browserName: 'chrome',
-      'goog:chromeOptions': {}
+    assert.ok(client.transport instanceof WebDriver);
+    assert.strictEqual(client.transport instanceof Selenium, false);
+    assert.deepStrictEqual(client.transport.desiredCapabilities, {
+      browserName: 'chrome'
     });
   });
 
@@ -163,17 +140,15 @@ describe('Transport.create()', function () {
       },
       desiredCapabilities: {
         browserName: 'chrome',
-        chromeOptions: {
+        'goog:chromeOptions': {
           w3c: true
         }
       }
     });
 
-    assert.strictEqual(client.transport instanceof JsonWire, false);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
-    assert.strictEqual(client.transport instanceof WebDriver, true);
-    assert.deepStrictEqual(client.session.desiredCapabilities, {
+    assert.ok(client.transport instanceof WebDriver);
+    assert.strictEqual(client.transport instanceof Selenium, false);
+    assert.deepStrictEqual(client.transport.desiredCapabilities, {
       browserName: 'chrome',
       'goog:chromeOptions': {
         w3c: true
@@ -188,17 +163,15 @@ describe('Transport.create()', function () {
       },
       desiredCapabilities: {
         browserName: 'chrome',
-        chromeOptions: {
+        'goog:chromeOptions': {
           w3c: false
         }
       }
     });
 
-    assert.strictEqual(client.transport instanceof JsonWire, true);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
-    assert.strictEqual(client.transport instanceof WebDriver, false);
-    assert.deepStrictEqual(client.session.desiredCapabilities, {
+    assert.ok(client.transport instanceof WebDriver);
+    assert.strictEqual(client.transport instanceof Selenium, false);
+    assert.deepStrictEqual(client.transport.desiredCapabilities, {
       browserName: 'chrome',
       'goog:chromeOptions': {
         w3c: false
@@ -213,17 +186,15 @@ describe('Transport.create()', function () {
       },
       desiredCapabilities: {
         browserName: 'MicrosoftEdge',
-        edgeOptions: {
+        'ms:edgeOptions': {
           w3c: true
         }
       }
     });
 
-    assert.strictEqual(client.transport instanceof JsonWire, false);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
-    assert.strictEqual(client.transport instanceof WebDriver, true);
-    assert.deepStrictEqual(client.session.desiredCapabilities, {
+    assert.ok(client.transport instanceof WebDriver);
+    assert.strictEqual(client.transport instanceof Selenium, false);
+    assert.deepStrictEqual(client.transport.desiredCapabilities, {
       browserName: 'MicrosoftEdge',
       'ms:edgeOptions': {
         w3c: true
@@ -241,13 +212,10 @@ describe('Transport.create()', function () {
       }
     });
 
-    assert.ok(client.transport instanceof JsonWire);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
-    assert.strictEqual(client.transport instanceof WebDriver, false);
-    assert.deepStrictEqual(client.session.desiredCapabilities, {
-      browserName: 'MicrosoftEdge',
-      'ms:edgeOptions': {}
+    assert.ok(client.transport instanceof WebDriver);
+    assert.strictEqual(client.transport instanceof Selenium, false);
+    assert.deepStrictEqual(client.transport.desiredCapabilities, {
+      browserName: 'MicrosoftEdge'
     });
   });
 
@@ -264,11 +232,9 @@ describe('Transport.create()', function () {
       }
     });
 
-    assert.strictEqual(client.transport instanceof JsonWire, true);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
-    assert.strictEqual(client.transport instanceof WebDriver, false);
-    assert.deepStrictEqual(client.session.desiredCapabilities, {
+    assert.strictEqual(client.transport instanceof Selenium, false);
+    assert.strictEqual(client.transport instanceof WebDriver, true);
+    assert.deepStrictEqual(client.transport.desiredCapabilities, {
       browserName: 'MicrosoftEdge',
       'ms:edgeOptions': {
         w3c: false
@@ -277,9 +243,7 @@ describe('Transport.create()', function () {
   });
 
   it('test create Transport for Safari managed', function() {
-    const Transport = common.require('transport/index.js');
-
-    let safariDriver = Transport.create({
+    let client = NightwatchClient.client({
       settings: {
         selenium: {
           start_process: false
@@ -293,7 +257,7 @@ describe('Transport.create()', function () {
       }
     });
 
-    assert.ok(safariDriver instanceof WebDriver);
+    assert.ok(client.transport instanceof WebDriver);
   });
 
   it('test create Transport for Safari remote', function() {
@@ -301,6 +265,7 @@ describe('Transport.create()', function () {
 
     let safariDriver = Transport.create({
       settings: {
+        use_selenium_webdriver: true,
         selenium: {
           start_process: false
         },
@@ -314,10 +279,8 @@ describe('Transport.create()', function () {
       }
     });
 
-    assert.ok(safariDriver instanceof JsonWire);
-    assert.strictEqual(safariDriver instanceof Selenium2, false);
-    assert.strictEqual(safariDriver instanceof Selenium3, false);
-    assert.strictEqual(safariDriver instanceof WebDriver, false);
+    assert.ok(safariDriver instanceof WebDriver);
+    assert.strictEqual(safariDriver instanceof Selenium, false);
   });
 
   it('test create Transport for Chrome managed and no selenium settings', function() {
@@ -325,6 +288,7 @@ describe('Transport.create()', function () {
 
     let chromeDriver = Transport.create({
       settings: {
+        use_selenium_webdriver: true,
         webdriver: {
           start_process: true
         },
@@ -334,10 +298,8 @@ describe('Transport.create()', function () {
       }
     });
 
-    assert.ok(chromeDriver instanceof JsonWire);
-    assert.strictEqual(chromeDriver instanceof Selenium2, false);
-    assert.strictEqual(chromeDriver instanceof Selenium3, false);
-    assert.strictEqual(chromeDriver instanceof WebDriver, false);
+    assert.ok(chromeDriver instanceof WebDriver);
+    assert.strictEqual(chromeDriver instanceof Selenium, false);
   });
 
   it('test create Transport for WebDriver managed and no selenium settings', function() {
@@ -351,8 +313,7 @@ describe('Transport.create()', function () {
     });
 
     assert.ok(client.transport instanceof WebDriver);
-    assert.strictEqual(client.transport instanceof Selenium2, false);
-    assert.strictEqual(client.transport instanceof Selenium3, false);
+    assert.strictEqual(client.transport instanceof Selenium, false);
   });
 
   it('test check for ssl when webdriver port is 443', function () {
@@ -360,6 +321,7 @@ describe('Transport.create()', function () {
 
     const instance = {
       settings: {
+        use_selenium_webdriver: true,
         webdriver: {
           start_process: true,
           port: 443,
@@ -386,18 +348,12 @@ describe('Transport.create()', function () {
       selenium_host: 'remote.host'
     });
 
-    assert.ok(client.transport instanceof Selenium2);
+    assert.ok(client.transport instanceof Selenium);
 
     const elementId = client.transport.getElementId({
       'element-6066-11e4-a52e-4f735466cecf': 'abcd-123'
     });
     assert.strictEqual(elementId, 'abcd-123');
-
-    const elementId2 = client.transport.getElementId({
-      ELEMENT: 'abcd-1234'
-    });
-    assert.strictEqual(elementId2, 'abcd-1234');
-
     assert.strictEqual(client.settings.webdriver.host, 'remote.host');
     assert.strictEqual(client.settings.webdriver.default_path_prefix, '/wd/hub');
   });
@@ -413,12 +369,12 @@ describe('Transport.create()', function () {
       selenium_host: 'remote.host'
     });
 
-    assert.ok(client.transport instanceof Selenium2);
+    assert.ok(client.transport instanceof Selenium);
     assert.strictEqual(client.settings.webdriver.host, 'remote.host');
     assert.strictEqual(client.settings.webdriver.default_path_prefix, '/wd/hub');
-    assert.strictEqual(client.transport instanceof Selenium3, false);
   });
 
+  //TODO: Make the test pass after browserstack works with selenium-webdriver
   it('test create Transport for Browserstack', function(done) {
     assert.throws(function() {
       NightwatchClient.client({
@@ -508,6 +464,7 @@ describe('Transport.create()', function () {
 
   });
 
+  //TODO: Make the test pass after browserstack works with selenium-webdriver
   it('test create Transport for Browserstack with failures', function(done) {
     const client = NightwatchClient.client({
       webdriver: {
diff --git a/test/src/index/testEdgeOptions.js b/test/src/index/testEdgeOptions.js
index d632cc2e..5d60cc79 100644
--- a/test/src/index/testEdgeOptions.js
+++ b/test/src/index/testEdgeOptions.js
@@ -110,5 +110,27 @@ describe('Test edge option', function(){
     assert.strictEqual(options instanceof EdgeOptions, true);
     assert.strictEqual(options.options_.androidPackage, 'com.android.edge');
   });
-  
+
+  it('proxy option', function(){
+    const client =  Nightwatch.createClient({
+      desiredCapabilities: {
+        browserName: 'edge',
+        proxy: {
+          https: 'localhost:8888'
+        }
+      }
+    });
+    const options = client.transport.createOptions();
+
+    assert.strictEqual(options instanceof EdgeOptions, true);
+    assert.deepStrictEqual(options.getProxy(), {
+      proxyType: 'manual',
+      sslProxy: 'localhost:8888',
+      ftpProxy: undefined,
+      httpProxy: undefined,
+      noProxy: undefined
+    });
+  });
+
+
 });
diff --git a/test/src/index/testFirefoxOptions.js b/test/src/index/testFirefoxOptions.js
index 3841f392..1112b72a 100644
--- a/test/src/index/testFirefoxOptions.js
+++ b/test/src/index/testFirefoxOptions.js
@@ -95,5 +95,26 @@ describe('Firefox driver options', function(){
     assert.strictEqual(options instanceof FirefoxOptions, true);
     assert.deepStrictEqual(options.get('moz:firefoxOptions').args, ['--width=100', '--height=100']);
   });
- 
+  
+  it('proxy options', function(){
+    const client = Nightwatch.createClient({
+      desiredCapabilities: {
+        proxy: {
+          https: 'localhost:8888'
+        },
+        browserName: 'firefox'
+      }
+    });
+    const options = client.transport.createOptions();
+
+    assert.strictEqual(options instanceof FirefoxOptions, true);
+    assert.deepStrictEqual(options.getProxy(), {
+      proxyType: 'manual',
+      sslProxy: 'localhost:8888',
+      ftpProxy: undefined,
+      httpProxy: undefined,
+      noProxy: undefined
+    });
+  });
+
 });
diff --git a/test/src/index/testSafariOptions.js b/test/src/index/testSafariOptions.js
index 248a2f48..6cc209d0 100644
--- a/test/src/index/testSafariOptions.js
+++ b/test/src/index/testSafariOptions.js
@@ -20,5 +20,27 @@ describe('Test safari options', function(){
     assert.strictEqual(options instanceof SafariOptions, true);
     assert.deepStrictEqual(options.options_.technologyPreview, true);
   });
-    
+
+  it('proxy option', function(){
+    const client =  Nightwatch.createClient({
+      desiredCapabilities: {
+        proxy: {
+          https: 'localhost:8888'
+        },
+        browserName: 'safari'
+      }
+    });
+    const options = client.transport.createOptions();
+
+    assert.strictEqual(options instanceof SafariOptions, true);
+    assert.deepStrictEqual(options.getProxy(), {
+      proxyType: 'manual',
+      sslProxy: 'localhost:8888',
+      ftpProxy: undefined,
+      httpProxy: undefined,
+      noProxy: undefined
+    });
+  });
+  
+
 });
\ No newline at end of file