<commit_before>module XPath
  module HTML
    include XPath
    extend self

    # Match an `a` link element.
    #
    # @param [String] locator
    #   Text, id, title, or image alt attribute of the link
    #
    def link(locator)
      link = descendant(:a)[attr(:href)]
      link[attr(:id).equals(locator) | string.n.is(locator) | attr(:title).is(locator) | descendant(:img)[attr(:alt).is(locator)]]
    end

    # Match a `submit`, `image`, or `button` element.
    #
    # @param [String] locator
    #   Value, title, id, or image alt attribute of the button
    #
    def button(locator)
      button = descendant(:input)[attr(:type).one_of('submit', 'image', 'button')][attr(:id).equals(locator) | attr(:value).is(locator) | attr(:title).is(locator)]
      button += descendant(:button)[attr(:id).equals(locator) | attr(:value).is(locator) | string.n.is(locator) | attr(:title).is(locator)]
      button += descendant(:input)[attr(:type).equals('image')][attr(:alt).is(locator)]
    end


    # Match anything returned by either {#link} or {#button}.
    #
    # @param [String] locator
    #   Text, id, title, or image alt attribute of the link or button
    #
    def link_or_button(locator)
      link(locator) + button(locator)
    end


    # Match any `fieldset` element.
    #
    # @param [String] locator
    #   Legend or id of the fieldset
    #
    def fieldset(locator)
      descendant(:fieldset)[attr(:id).equals(locator) | child(:legend)[string.n.is(locator)]]
    end


    # Match any `input`, `textarea`, or `select` element that doesn't have a
    # type of `submit`, `image`, or `hidden`.
    #
    # @param [String] locator
    #   Label, id, or name of field to match
    #
    def field(locator)
      xpath = descendant(:input, :textarea, :select)[~attr(:type).one_of('submit', 'image', 'hidden')]
      xpath = locate_field(xpath, locator)
      xpath
    end


    # Match any `input` or `textarea` element that can be filled with text.
    # This excludes any inputs with a type of `submit`, `image`, `radio`,
    # `checkbox`, `hidden`, or `file`.
    #
    # @param [String] locator
    #   Label, id, or name of field to match
    #
    def fillable_field(locator)
      xpath = descendant(:input, :textarea)[~attr(:type).one_of('submit', 'image', 'radio', 'checkbox', 'hidden', 'file')]
      xpath = locate_field(xpath, locator)
      xpath
    end


    # Match any `select` element.
    #
    # @param [String] locator
    #   Label, id, or name of the field to match
    #
    def select(locator)
      locate_field(descendant(:select), locator)
    end


    # Match any `input` element of type `checkbox`.
    #
    # @param [String] locator
    #   Label, id, or name of the checkbox to match
    #
    def checkbox(locator)
      xpath = locate_field(descendant(:input)[attr(:type).equals('checkbox')], locator)
    end


    # Match any `input` element of type `radio`.<commit_msg>suppress a warning:<commit_after>module XPath
  module HTML
    include XPath
    extend self

    # Match an `a` link element.
    #
    # @param [String] locator
    #   Text, id, title, or image alt attribute of the link
    #
    def link(locator)
      link = descendant(:a)[attr(:href)]
      link[attr(:id).equals(locator) | string.n.is(locator) | attr(:title).is(locator) | descendant(:img)[attr(:alt).is(locator)]]
    end

    # Match a `submit`, `image`, or `button` element.
    #
    # @param [String] locator
    #   Value, title, id, or image alt attribute of the button
    #
    def button(locator)
      button = descendant(:input)[attr(:type).one_of('submit', 'image', 'button')][attr(:id).equals(locator) | attr(:value).is(locator) | attr(:title).is(locator)]
      button += descendant(:button)[attr(:id).equals(locator) | attr(:value).is(locator) | string.n.is(locator) | attr(:title).is(locator)]
      button += descendant(:input)[attr(:type).equals('image')][attr(:alt).is(locator)]
    end


    # Match anything returned by either {#link} or {#button}.
    #
    # @param [String] locator
    #   Text, id, title, or image alt attribute of the link or button
    #
    def link_or_button(locator)
      link(locator) + button(locator)
    end


    # Match any `fieldset` element.
    #
    # @param [String] locator
    #   Legend or id of the fieldset
    #
    def fieldset(locator)
      descendant(:fieldset)[attr(:id).equals(locator) | child(:legend)[string.n.is(locator)]]
    end


    # Match any `input`, `textarea`, or `select` element that doesn't have a
    # type of `submit`, `image`, or `hidden`.
    #
    # @param [String] locator
    #   Label, id, or name of field to match
    #
    def field(locator)
      xpath = descendant(:input, :textarea, :select)[~attr(:type).one_of('submit', 'image', 'hidden')]
      xpath = locate_field(xpath, locator)
      xpath
    end


    # Match any `input` or `textarea` element that can be filled with text.
    # This excludes any inputs with a type of `submit`, `image`, `radio`,
    # `checkbox`, `hidden`, or `file`.
    #
    # @param [String] locator
    #   Label, id, or name of field to match
    #
    def fillable_field(locator)
      xpath = descendant(:input, :textarea)[~attr(:type).one_of('submit', 'image', 'radio', 'checkbox', 'hidden', 'file')]
      xpath = locate_field(xpath, locator)
      xpath
    end


    # Match any `select` element.
    #
    # @param [String] locator
    #   Label, id, or name of the field to match
    #
    def select(locator)
      locate_field(descendant(:select), locator)
    end


    # Match any `input` element of type `checkbox`.
    #
    # @param [String] locator
    #   Label, id, or name of the checkbox to match
    #
    def checkbox(locator)
      locate_field(descendant(:input)[attr(:type).equals('checkbox')], locator)
    end


    # Match any `input` element of type `radio`.
{'fraction_non_alphanumeric': 0.14728946471189908, 'fraction_numerical': 0.0, 'mean_word_length': 3.0157426420260096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1154330', 'n_tokens_mistral': 1936, 'n_tokens_neox': 1886, 'n_words': 528}