/**
     * It will return the slector strategy for the given selector string
     */
    getSelectorStrategy: function (locator) {
        if (locator.startsWith("//")) {
            return "xpath";
        } else {
            return "css selector";
        }
    } Using above method, elements method can be implemented as below
const {client} = require('nightwatch-cucumber');
 /**
   * This will retrun array of elements for the given selectors
   */
   getElements: function (locator, callback) {
       var selectorStrategy = this.getSelectorStrategy(locator);
       return client.elements(selectorStrategy, locator, function (result) {
           callback(result.value)
       });
    } 
