Sha256: 798d566bd0baee91042d3d37d0322a9b7620829e474aaf8c1a8f6e72d46fdb58
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' module Watir module Container def input_label(label) what = self.label(:text, label).for raise "label for attribute is blank" if what == "" input_id(what) end # If user knowns the Label that has a for attribute pointing to an element we can access that element by # input_element(:lable, 'Text Of Label') def input_id(what) raise "provide a String for Id" unless what.kind_of?(String) # for input_element('bla') convention to (:id,'bla') mystery_element = self.document.getElementById(what) raise 'Element not found' unless mystery_element mystery_type = mystery_element.invoke('type') return text_field(:id, what) if TextField::INPUT_TYPES.include? mystery_type return select_list(:id, what) if SelectList::INPUT_TYPES.include? mystery_type # TODO working on this end end end describe 'Mystery input element' do include Watirloo::Page before do browser.goto testfile('labels.html') end it 'the id is text_field' do browser.input_id('first_nm').should be_kind_of(Watir::TextField) end it 'the label points to text_field' do browser.input_label('FirstName For').should be_kind_of(Watir::TextField) end it "the id should return select_list" do browser.input_id('gender_code').should be_kind_of(Watir::SelectList) end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
marekj-watirloo-0.0.5 | spec/input_element_spec.rb |
watirloo-0.0.8 | spec/input_element_spec.rb |
watirloo-0.0.7 | spec/input_element_spec.rb |