code: def field_xpath(field, attribute):
      
      if field in ['select', 'textarea']:
          xpath = './/{field}[@{attr}=%s]'
  
      elif field == 'button-role':
          if attribute == 'value':
              xpath = './/*[@role="button"][contains(., %s)]'
          else:
              xpath = './/*[@role="button"][@{attr}=%s]'
  
      elif field == 'button-element':
          field = 'button'
          if attribute == 'value':
              xpath = './/{field}[contains(., %s)]'
          else:
              xpath = './/{field}[@{attr}=%s]'
  
      elif field == 'option':
          xpath = './/{field}[@{attr}=%s]'
  
      else:
          xpath = './/input[@{attr}=%s][@type="{field}"]'
  
      return xpath.format(field=field, attr=attribute)
docs: Field helper functions to locate select, textarea, and the other
      types of input fields (text, checkbox, radio)
  
      :param field: One of the values 'select', 'textarea', 'option', or
      'button-element' to match a corresponding HTML element (and to
      match a <button> in the case of 'button-element'). Otherwise a
      type to match an <input> element with a type=<field> attribute.
  
      :param attribute: An attribute to be matched against, or 'value'
      to match against the content within element being matched.