Sha256: 40fce06ff85589ebe1394a4caf37a294f8a9fc9c2a70e21d84739ca7a2d5ee52

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

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
      expect(Browser.attach(:title, /Images/).hwnd).to eq(browser.hwnd)
    end

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

    it "attaches to existing browser by handle" do
      expect(Browser.attach(:hwnd, browser.hwnd).hwnd).to eq(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

2 entries across 2 versions & 1 rubygems

Version Path
watir-classic-4.3.0 spec/browser_spec.rb
watir-classic-4.2.0 spec/browser_spec.rb