<commit_before>require 'watirspec_helper'

describe 'Browser' do
  before do
    url = WatirSpec.url_for('window_switching.html')
    browser.goto url
    browser.a(id: 'open').click
    Watir::Wait.until { browser.windows.size == 2 }
  end

  after do
    browser.original_window.use
    browser.windows.reject(&:current?).each(&:close)
  end

  describe '#windows' do
    it 'returns an array of window handles' do
      wins = browser.windows
      expect(wins).to_not be_empty
      wins.each { |win| expect(win).to be_kind_of(Watir::Window) }
    end

    it 'only returns windows matching the given selector' do
      expect(browser.windows(title: 'closeable window').size).to eq 1
    end

    it 'raises ArgumentError if the selector is invalid' do
      expect { browser.windows(name: 'foo') }.to raise_error(ArgumentError)
    end

    it 'returns an empty array if no window matches the selector' do
      expect(browser.windows(title: 'noop')).to eq []
    end
  end
<commit_msg>fix frequent race condition in spec on Firefox<commit_after>require 'watirspec_helper'

describe 'Browser' do
  before do
    url = WatirSpec.url_for('window_switching.html')
    browser.goto url
    browser.a(id: 'open').click
    Watir::Wait.until { browser.windows.size == 2 }
  end

  after do
    browser.original_window.use
    browser.windows.reject(&:current?).each(&:close)
  end

  describe '#windows' do
    it 'returns an array of window handles' do
      wins = browser.windows
      expect(wins).to_not be_empty
      wins.each { |win| expect(win).to be_kind_of(Watir::Window) }
    end

    it 'only returns windows matching the given selector' do
      browser.wait_until { |b| b.window(title: 'closeable window').exists? }
      expect(browser.windows(title: 'closeable window').size).to eq 1
    end

    it 'raises ArgumentError if the selector is invalid' do
      expect { browser.windows(name: 'foo') }.to raise_error(ArgumentError)
    end

    it 'returns an empty array if no window matches the selector' do
      expect(browser.windows(title: 'noop')).to eq []
    end
  end

{'fraction_non_alphanumeric': 0.10659655831739961, 'fraction_numerical': 0.0019120458891013384, 'mean_word_length': 3.2889344262295084, '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': '1199995', 'n_tokens_mistral': 658, 'n_tokens_neox': 638, 'n_words': 190}