javascript/node/selenium-webdriver/lib/by.js
function check(locator) {
  if (locator instanceof By || typeof locator === 'function') {
    return locator;
  }

  if (locator
      && typeof locator === 'object'
      && typeof locator.using === 'string'
      && typeof locator.value === 'string') {
    return new By(locator.using, locator.value);
  }

  for (let key in locator) {
    if (locator.hasOwnProperty(key) && By.hasOwnProperty(key)) {
      return By[key](locator[key]);
    }
  }
  throw new TypeError('Invalid locator');
}
function check(locator) {
  if (locator instanceof By || typeof locator === 'function') {
    return locator;
  }

  if (locator
      && typeof locator === 'object'
      && typeof locator.using === 'string'
      && typeof locator.value === 'string') {
    return new By(locator.using, locator.value);
  }

  for (let key in locator) {
    if (locator.hasOwnProperty(key) && By.hasOwnProperty(key)) {
      return By[key](locator[key]);
    }
  }
  throw new TypeError('Invalid locator');
}
function check ( locator ) { if ( locator instanceof By || typeof locator === 'function' ) { return locator ; } if ( locator && typeof locator === 'object' && typeof locator . using === 'string' && typeof locator . value === 'string' ) { return new By ( locator . using , locator . value ) ; } for ( let key in locator ) { if ( locator . hasOwnProperty ( key ) && By . hasOwnProperty ( key ) ) { return By [ key ] ( locator [ key ] ) ; } } throw new TypeError ( 'Invalid locator' ) ; }
Checks if a value is a valid locator.
@param {!(By|Function|ByHash)} locator The value to check.
@return {!(By|Function)} The valid locator.
@throws {TypeError} If the given value does not define a valid locator
strategy.
Checks if a value is a valid locator .