<commit_before>$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
require 'unittests/setup'

class TC_ElementCollections < Test::Unit::TestCase
  include Watir::Exception
  
  def setup
    goto_page "multiple_specifiers.html"
  end

  def test_input_element_specifiers
    buttons = browser.buttons(:class, "two")
    assert 1, buttons.length
    assert "testbutton", buttons[0].name
    assert "two", buttons[0].class_name

    buttons = browser.buttons(:name, "testbutton")
    assert 2, buttons.length
    buttons.each do |btn|
      assert Watir::Button, btn.class
    end
    assert "testbutton", buttons[0].name    
    assert "one", buttons[0].class_name
    assert "testbutton", buttons[1].name
    assert "two", buttons[1].class_name
  end

  def test_brackets
    assert browser.buttons[0], browser.buttons(:class => "one")
    assert browser.buttons[1].exists?
    assert_raise(Watir::Exception::UnknownObjectException) {browser.buttons[2].exists?}
    assert_raise(Watir::Exception::UnknownObjectException) {browser.buttons[-1].exists?}
  end

  def test_first
    assert browser.buttons.first, browser.buttons(:class, "one")
  end

  def test_last
    assert browser.buttons.last, browser.buttons(:class => "two")<commit_msg>update test case for changes to collections<commit_after>$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
require 'unittests/setup'

class TC_ElementCollections < Test::Unit::TestCase
  include Watir::Exception
  
  def setup
    goto_page "multiple_specifiers.html"
  end

  def test_input_element_specifiers
    buttons = browser.buttons(:class, "two")
    assert 1, buttons.length
    assert "testbutton", buttons[0].name
    assert "two", buttons[0].class_name

    buttons = browser.buttons(:name, "testbutton")
    assert 2, buttons.length
    buttons.each do |btn|
      assert Watir::Button, btn.class
    end
    assert "testbutton", buttons[0].name    
    assert "one", buttons[0].class_name
    assert "testbutton", buttons[1].name
    assert "two", buttons[1].class_name
  end

  def test_brackets
    assert browser.buttons[0], browser.buttons(:class => "one")
    assert browser.buttons[1].exists?
    assert browser.buttons[2].exists? == false
    assert_raise(Watir::Exception::UnknownObjectException) {browser.buttons[2].click}
  end

  def test_first
    assert browser.buttons.first, browser.buttons(:class, "one")
  end

  def test_last
    assert browser.buttons.last, browser.buttons(:class => "two")
{'fraction_non_alphanumeric': 0.12212529738302934, 'fraction_numerical': 0.00951625693893735, 'mean_word_length': 4.25625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2879679', 'n_tokens_mistral': 783, 'n_tokens_neox': 757, 'n_words': 170}