Sha256: c1e3d266f0a57930a8bb094748d53e4dc1c3b46dd65aa626047ad278423ecbea

Contents?: true

Size: 1014 Bytes

Versions: 11

Compression:

Stored size: 1014 Bytes

Contents

require File.expand_path("watirspec/spec_helper", File.dirname(__FILE__))

describe "Browser" do
  before do
    browser.goto(WatirSpec.url_for("images.html"))
  end

  context "#attach" do
    it "attaches to existing browser by title" do
      Browser.attach(:title, /Images/).hwnd.should == browser.hwnd
    end

    it "attaches to existing browser by url" do
      Browser.attach(:url, /images\.html/).hwnd.should == browser.hwnd
    end

    it "attaches to existing browser by handle" do
      Browser.attach(:hwnd, browser.hwnd).hwnd.should == browser.hwnd
    end

    it "fails with an error if specified browser was not found" do
      begin
        original_timeout = browser.class.attach_timeout
        browser.class.attach_timeout = 0.1

        expect {
          Browser.attach(:title, "not-existing-window")
        }.to raise_error(NoMatchingWindowFoundException)
      ensure
        browser.class.attach_timeout = original_timeout
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
watir-classic-4.1.0 spec/browser_spec.rb
watir-classic-4.0.1 spec/browser_spec.rb
watir-classic-4.0.0 spec/browser_spec.rb
watir-classic-3.7.0 spec/browser_spec.rb
watir-classic-3.6.0 spec/browser_spec.rb
watir-classic-3.5.0 spec/browser_spec.rb
watir-classic-3.4.0 spec/browser_spec.rb
watir-classic-3.3.0 spec/browser_spec.rb
watir-classic-3.2.0 spec/browser_spec.rb
watir-classic-3.2.0.rc1 spec/browser_spec.rb
watir-classic-3.1.0 spec/browser_spec.rb