Sha256: 4fc8e6ac99deafee0aae9418f9fd840819aab1a9e044e7d530c5d13fe434fb91

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'
require 'page-object/elements'


describe PageObject::Elements::Element do
  let(:watir_driver) { double('watir') }
  let(:selenium_driver) { double('selenium') }
  let(:watir_element) { PageObject::Elements::Element.new(watir_driver, :platform => :watir) }
  let(:selenium_element) { PageObject::Elements::Element.new(selenium_driver, :platform => :selenium) }

  context "on a Watir page-object" do
    it "should know when it is visible" do
      watir_driver.should_receive(:present?).and_return(true)
      watir_element.visible?.should == true
    end
    
    it "should know when it is not visible" do
      watir_driver.should_receive(:present?).and_return(false)
      watir_element.visible?.should == false
    end
    
    it "should know when it exists" do
      watir_driver.should_receive(:exists?).and_return(true)
      watir_element.exists?.should == true
    end
    
    it "should know when it does not exist" do
      watir_driver.should_receive(:exists?).and_return(false)
      watir_element.exists?.should == false
    end
  end
  
  context "on a Selenium page-object" do
    it "should know when it is visible" do
      selenium_driver.should_receive(:displayed?).and_return(true)
      selenium_element.visible?.should == true
    end
    
    it "should know when it is not visible" do
      selenium_driver.should_receive(:displayed?).and_return(false)
      selenium_element.visible?.should == false
    end
    
    it "should know when it exists" do
      selenium_element.exists?.should == true      
    end
    
    it "should know when it does not exist" do
      selenium_element = PageObject::Elements::Element.new(nil, :platform => :selenium)
      selenium_element.exists?.should == false
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
page-object-0.0.1 spec/page-object/elements/element_spec.rb