/**
 * Gets XPath selector for element containing text
 * @param text
 * @param el
 * @param className
 * @param child
 * @returns {{selector: string, locateStrategy: string}}
 */
function getSelectorForElementWithText (text, { el = '//*', className, child, hasExactText = false } = {}) {
  const classNameContains = className ? ` and contains(@class, "${className}")` : ''
  const textMatch = hasExactText ? `./text()="${text}"` : `contains(.,"${text}")`

  return {
    selector: `${el}[${textMatch}${classNameContains}]${child || ''}`,
    locateStrategy: 'xpath',
  }
}

/**
 * Gets XPath selector for button containing text
 * @param text
 * @returns {{selector: string, locateStrategy: string}}
 */
function getButtonWithText (text) {
  return getSelectorForElementWithText(text, { el: '//*', className: 'button' })
}

/**
 * Gets XPath selector for the value of a details table key value pair
 * @param text
 * @returns {{selector: string, locateStrategy: string}}
 */
function getKeyValueTableRowValueCell (text) {
  return getSelectorForElementWithText(
    text,
    {
      el: '//th',
      child: '/following-sibling::td',
      hasExactText: true,
    }
  )
}

/**
 * Gets XPath selector the selector for the meta item label value from entity lists
 * @param text
 * @returns {{selector: string, locateStrategy: string}}
 */
function getMetaListItemValueSelector (text) {
  return getSelectorForElementWithText(
    text,
    {
      el: '//span',
      className: 'c-meta-list__item-label',
      child: '/following-sibling::span',
    }
  )
}

/**
 * Gets XPath selector for getting a meta list item from a specific item in a collection item
 * @param text
 * @param [listItem=1]
 */
const getListItemMetaElementWithText = (text, listItem = 1) => getSelectorForElementWithText(
  text,
  {
    el: `//article[contains(@class, "c-collection")]//ol[contains(@class,"c-entity-list")]/li[${listItem}]//span`,
    className: 'c-meta-list__item-label',
    child: '/following-sibling::span',
  }
)

/**
 * Gets XPath selector for an anchor tag containing text
 * @param text
 * @param className
 * @returns {{selector: string, locateStrategy: string}}
 */
function getLinkWithText (text, className) {
  return getSelectorForElementWithText(
    text,
    {
      el: '//a',
      className,
    },
  )
}

/**
 * Gets XPath selector for an anchor tag following a specified section
 * @param sectionTitle
 * @param buttonText
 * @returns {{selector: string, locateStrategy: string}}
 */
const getSelectorForDetailsSectionEditButton = (sectionTitle, buttonText = 'Edit') => {
  return getSelectorForElementWithText(sectionTitle, {
    el: '//h2',
    child: '/following-sibling::p[1]/a[contains(.,"Edit")]',
  })
}

module.exports = {
  getSelectorForElementWithText,
  getButtonWithText,
  getKeyValueTableRowValueCell,
  getMetaListItemValueSelector,
  getLinkWithText,
  getListItemMetaElementWithText,
  getSelectorForDetailsSectionEditButton,
}

@@ -1160,32 +1160,239 @@
 e,%0A    %7D%0A  )%0A%7D%0A%0A
+function getDataTableRowCell (text, index) %7B%0A  return getSelectorForElementWithText(%0A    text,%0A    %7B%0A      el: '//td',%0A      child: %60/following-sibling::td%5B$%7Bindex%7D%5D%60,%0A      hasExactText: true,%0A    %7D%0A  )%0A%7D%0A%0A
 /**%0A * Gets XPat
@@ -3028,16 +3028,39 @@
 ueCell,%0A
+  getDataTableRowCell,%0A
   getMet

Add selector for getting data table row cell