Sha256: 41059c80ba2f74ee6d76c86c8cb9d248770531ab071bb4ba4184f1dd0b18fe5f

Contents?: true

Size: 1.64 KB

Versions: 3

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("window.originalOnErrorExecuted").should_not be_true

    expect {
      browser.link(:id => "errorLink").click
    }.to raise_error(WatirSplash::JavaScriptError, /JavaScript error:.*unexistingVar/)
    browser.execute_script("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

3 entries across 3 versions & 1 rubygems

Version Path
watirsplash-2.4.2 spec/browser_spec.rb
watirsplash-2.4.1 spec/browser_spec.rb
watirsplash-2.4.0 spec/browser_spec.rb