Sha256: 7f94c3e86976975f379ac959aadaf22226e3232d71da07ff2494dcc3151444c4

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'
require 'thread'

# This is more of an example of using Watirloo::browser() and Watirloo::Locker with threads
# for multibrowser testing possiblilities
describe "Watirloo multiple browsers and threads" do

  before(:all) do
    Watirloo::Desktop.clear
    Watirloo::Locker.clear
  end


  it "open 5 new browsers in threads and add them to locker"  do
    threads = []
    1.upto(5) do |i|
      threads << Thread.new { Watirloo.browser(i) }
    end
    threads.each {|x| x.join}
  end

  it 'use locker to reattach to 5 browsers and load 5 diff pages at once' do
    threads = []
    files = ['census.html', 'labels.html', 'person.html', 'select_lists.html', 'radio_group.html']
    titles = ['Census', 'Labels', 'Person', 'select lists', "radio_groups"]
    1.upto(5) do |i|
      threads << Thread.new do
        Watirloo.browser(i).goto testfile(files[i-1])
        sleep 5 #add safety
        Watirloo.browser(i).title.should == titles[i-1]
      end
    end
    threads.each {|x| x.join}
  end

  it "reattach and close all 5 browsers" do
    hwnds = Watirloo::Desktop.hwnds
    threads =[]
    1.upto(5) { |i| threads << Thread.new { Watirloo.browser(i).close } }
    threads.each {|x| x.join}
    sleep 5 #Ensure browsers close
    Watirloo::Desktop.deletions(hwnds).size.should == 5
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
marekj-watirloo-0.0.5 spec/browser_threads_spec.rb
watirloo-0.0.8 spec/browser_threads_spec.rb
watirloo-0.0.7 spec/browser_threads_spec.rb