Sha256: 5d3e1f517fc6236a1b0684e02dc362240882afd97e55b5d62e5c0d597e149e24

Contents?: true

Size: 1.6 KB

Versions: 34

Compression:

Stored size: 1.6 KB

Contents

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

describe PageObject::Elements::TextField do

  describe "when mapping how to find an element" do
    let(:textfield) { PageObject::Elements::TextField }

    it "should map watir types to same" do
      [:class, :id, :index, :name, :title, :xpath, :text, :label].each do |t|
        identifier = textfield.watir_identifier_for t => 'value'
        identifier.keys.first.should == t
      end
    end

    it "should map selenium types to same" do
      [:class, :id, :name, :title, :xpath, :index, :text, :label].each do |t|
        key, value = textfield.selenium_identifier_for t => 'value'
        key.should == t
      end
    end
  end
  
  describe "interface" do
    let(:text_field_element) { double('text_field') }
    let(:selenium_text_field) { PageObject::Elements::TextField.new(text_field_element, :platform => :selenium_webdriver) }

    it "should register with type :text" do
      ::PageObject::Elements.element_class_for(:input, :text).should == ::PageObject::Elements::TextField
    end

    it "should register with type :password" do
      ::PageObject::Elements.element_class_for(:input, :password).should == ::PageObject::Elements::TextField
    end

    it "should append text" do
      text_field_element.should_receive(:send_keys).with('abc')
      selenium_text_field.append('abc')
    end
    
    context "for selenium" do
      it "should set its' value" do
        text_field_element.should_receive(:clear)
        text_field_element.should_receive(:send_keys).with('Joseph')
        selenium_text_field.value = 'Joseph'
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
meeane-page-object-0.1.11 spec/page-object/elements/selenium/text_field_spec.rb
page-object-1.0.2 spec/page-object/elements/selenium/text_field_spec.rb
page-object-1.0.1 spec/page-object/elements/selenium/text_field_spec.rb
page-object-1.0 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.8 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.7 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.6 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.5 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.4 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.3 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.2 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.1 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.9.0 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.8.10 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.8.9 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.8.8 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.8.7 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.8.6.1 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.8.6 spec/page-object/elements/selenium/text_field_spec.rb
page-object-0.8.5 spec/page-object/elements/selenium/text_field_spec.rb