lib/commands/find.js
function stripViewFromSelector (selector) {
    // Don't strip it out if it's one of these 4 element types
    // (see https://github.com/facebook/WebDriverAgent/blob/master/WebDriverAgentLib/Utilities/FBElementTypeTransformer.m for reference)
    const keepView = [
      'XCUIElementTypeScrollView',
      'XCUIElementTypeCollectionView',
      'XCUIElementTypeTextView',
      'XCUIElementTypeWebView',
    ].includes(selector);

    if (!keepView && selector.indexOf('View') === selector.length - 4) {
      return selector.substr(0, selector.length - 4);
    } else {
      return selector;
    }
  }
function stripViewFromSelector (selector) {
    // Don't strip it out if it's one of these 4 element types
    // (see https://github.com/facebook/WebDriverAgent/blob/master/WebDriverAgentLib/Utilities/FBElementTypeTransformer.m for reference)
    const keepView = [
      'XCUIElementTypeScrollView',
      'XCUIElementTypeCollectionView',
      'XCUIElementTypeTextView',
      'XCUIElementTypeWebView',
    ].includes(selector);

    if (!keepView && selector.indexOf('View') === selector.length - 4) {
      return selector.substr(0, selector.length - 4);
    } else {
      return selector;
    }
  }
function stripViewFromSelector ( selector ) { // Don't strip it out if it's one of these 4 element types // (see https://github.com/facebook/WebDriverAgent/blob/master/WebDriverAgentLib/Utilities/FBElementTypeTransformer.m for reference) const keepView = [ 'XCUIElementTypeScrollView' , 'XCUIElementTypeCollectionView' , 'XCUIElementTypeTextView' , 'XCUIElementTypeWebView' , ] . includes ( selector ) ; if ( ! keepView && selector . indexOf ( 'View' ) === selector . length - 4 ) { return selector . substr ( 0 , selector . length - 4 ) ; } else { return selector ; } }
Check if the word 'View' is appended to selector and if it is, strip it out
Check if the word View is appended to selector and if it is strip it out