Sha256: 5577feb1d7d5556011fa1b5ab661d32b237e82397e8aafa68ff25598ab6cff1a

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

describe WatirSplash::Browser do

  before :all do
    # close the browser opened in environment.rb
    WatirSplash::Browser.current.close
  end

  it "opens up the browser" do
    browser = WatirSplash::Browser.new
    browser.should exist
    browser.should respond_to(:title)
  end

  it "stores the current browser" do
    browser = WatirSplash::Browser.new
    browser.should == WatirSplash::Browser.current
  end

  it "detects JavaScript errors" do
    browser = WatirSplash::Browser.new
    browser.goto "http://dl.dropbox.com/u/2731643/WatirSplash/test.html"
    browser.execute_script("return window.originalOnErrorExecuted").should be_nil

    expect {
      browser.link(:id => "errorLink").click
    }.to raise_error(WatirSplash::JavaScriptError, /JavaScript error:.*unexistingVar/)
    browser.execute_script("return window.originalOnErrorExecuted").should be_true    

    expect {
      browser.link(:id => "toggle").click
    }.not_to raise_error
  end

  it ".exist? && .exists?" do
    WatirSplash::Browser.current = nil
    WatirSplash::Browser.should_not exist

    WatirSplash::Browser.new
    WatirSplash::Browser.should exist

    WatirSplash::Browser.close
    WatirSplash::Browser.should_not exist

    WatirSplash::Browser.should respond_to(:exists?)
  end

  it "redirects missing method calls to browser object" do
    b = WatirSplash::Browser.new
    WatirSplash::Browser.should_not respond_to(:goto)
    expect {
      WatirSplash::Browser.goto "google.com"
    }.to_not raise_exception
    b.title.should =~ /google/i
  end

  after :each do
    WatirSplash::Browser.current.close
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watirsplash-2.4.4 spec/browser_spec.rb
watirsplash-2.4.3 spec/browser_spec.rb