<commit_before>Feature: Form Fields: Select

  Background:
    Given the following HTML:
      """
      <form>
        <select name="number">
          <option value="1" selected>One</option>
          <option value="2">Two</option>
          <option value="3">Three</option>
        </select>
      </form>
      """
    And the following widget definition:
      """
      class MyForm < Capybara::UI::Form
        select :my_select, 'number'
      end
      """

  Scenario: selected option
    Then we can get the text of the selected option with:
      """
      widget(:my_form).my_select #=> "One"
      """
    And we can get the value of the selected option with:
      """
      widget(:my_form).my_select_value #=> "1"
      """

  Scenario: selecting an option
    Then we can change the value of the select to "Two" with:
      """
      widget(:my_form).my_select = "Two"
      """
    And we can change the value of the select to "Three" with:
      """
      widget(:my_form).my_select = /Thr/
      """

  Scenario: invalid option
    When we try to change the value of the select to an invalid value:
      """
      widget(:my_form).my_select = "Four"
      """
    Then we will get the error Capybara::UI::InvalidOption

  Scenario:
    Given the following HTML:
      """
      <form>
        <select name="number">
          <option disabled="disabled">-- Escolha Um --</option>
          <option>Um</option>
          <option>Dois<option>
        </select>
      </form>
      """
    Then we will see no option is selected:
      """
      widget(:my_form).my_select #=> nil
      """<commit_msg>Update test for current browser behavior<commit_after>Feature: Form Fields: Select

  Background:
    Given the following HTML:
      """
      <form>
        <select name="number">
          <option value="1" selected>One</option>
          <option value="2">Two</option>
          <option value="3">Three</option>
        </select>
      </form>
      """
    And the following widget definition:
      """
      class MyForm < Capybara::UI::Form
        select :my_select, 'number'
      end
      """

  Scenario: selected option
    Then we can get the text of the selected option with:
      """
      widget(:my_form).my_select #=> "One"
      """
    And we can get the value of the selected option with:
      """
      widget(:my_form).my_select_value #=> "1"
      """

  Scenario: selecting an option
    Then we can change the value of the select to "Two" with:
      """
      widget(:my_form).my_select = "Two"
      """
    And we can change the value of the select to "Three" with:
      """
      widget(:my_form).my_select = /Thr/
      """

  Scenario: invalid option
    When we try to change the value of the select to an invalid value:
      """
      widget(:my_form).my_select = "Four"
      """
    Then we will get the error Capybara::UI::InvalidOption

  Scenario:
    Given the following HTML:
      """
      <form>
        <select name="number">
          <option disabled="disabled">-- Escolha Um --</option>
          <option>Um</option>
          <option>Dois<option>
        </select>
      </form>
      """
    Then we will see the first enabled option is selected:
      """
      widget(:my_form).my_select #=> "Um"
      """
{'fraction_non_alphanumeric': 0.12663622526636226, 'fraction_numerical': 0.0024353120243531205, 'mean_word_length': 2.0941619585687383, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 49, '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': '4812934', 'n_tokens_mistral': 963, 'n_tokens_neox': 945, 'n_words': 301}