Sha256: 210b32b2e4c2e038d09c3c311a0753fcecd3bc4f0164238b0c8a137f0b6c7ca9

Contents?: true

Size: 1.77 KB

Versions: 8

Compression:

Stored size: 1.77 KB

Contents

require "spec"

describe Watir::Element do

  before :each do
    goto "http://dl.dropbox.com/u/2731643/WatirSplash/test.html"
    @div = div(:id => 'div1')
  end

  it "has method #present?" do
    @div.should exist
    @div.should be_visible
    @div.should be_present

    execute_script("toggle()")
    @div.should exist
    @div.should_not be_visible
    @div.should_not be_present

    div = div(:id => 'non-existing')
    div.should_not exist
    lambda {div.visible?}.should raise_exception
    div.should_not be_present
  end

  it "has method #when_present" do
    @div.should be_visible
    @div.when_present.text.should == "Div content"
    link(:id => "toggle").click
    wait_until {not @div.visible?}

    link(:id => "toggle").click
    @div.when_present.text.should == "Div content"
    @div.should be_visible

    @div.when_present {1 + 1}.should == 2

    lambda {div(:id => 'non-existing').when_present(0.1).text}.should raise_exception
  end

  it "has method #wait_until_present" do
    @div.should be_visible
    @div.wait_until_present
    @div.text.should == "Div content"
    link(:id => "toggle").click
    wait_until {not @div.visible?}

    link(:id => "toggle").click
    @div.wait_until_present
    @div.text.should == "Div content"
    @div.should be_visible

    lambda {div(:id => 'non-existing').wait_until_present(0.1)}.should raise_exception
  end

  it "has method #wait_while_present" do
    @div.should be_visible
    link(:id => "toggle").click
    @div.wait_while_present
    @div.should_not be_visible

    link(:id => "toggle").click
    @div.wait_while_present
    @div.should_not be_visible

    wait_until {@div.visible?}
    lambda {@div.wait_while_present(0.1)}.should raise_exception
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
watirsplash-0.2.14 spec/watir_element_spec.rb
watirsplash-0.2.12 spec/watir_element_spec.rb
watirsplash-0.2.11 spec/watir_element_spec.rb
watirsplash-0.2.10 spec/watir_element_spec.rb
watirsplash-0.2.9 spec/watir_element_spec.rb
watirsplash-0.2.8 spec/watir_element_spec.rb
watirsplash-0.2.7 spec/watir_element_spec.rb
watirsplash-0.2.6 spec/watir_element_spec.rb