Sha256: bc6a088048dd4a782d3753f7ade48de62764c5cc6b2d4bacac50e0442725f9f7

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe 'RadioGroup class access in watir browser' do
  include Watirloo::Page

  before :each do
    browser.goto testfile('radio_group.html')
  end
  
  it 'browser responds to radio_group' do
    browser.should respond_to(:radio_groups)
  end
  
  it 'returns RadioGroups class' do
    browser.radio_groups.should be_kind_of(Watir::RadioGroups)
  end
  
  it 'lenght returns integer count of groups' do
    browser.radio_groups.length.should == 2
  end
  
  it 'each iterator returns RadioGroup' do
    browser.radio_groups.each do |rg|
      rg.class.should == Watir::RadioGroup #single
    end
  end
  
  it 'each accesses the group and returns name' do
    names =[]
    browser.radio_groups.each do |rg|
      names << rg.name
    end
    names.should == ['food', 'fooda']
  end
  
  it 'bracket access[] returns 1-based indexed group' do
    browser.radio_groups[1].class.should == Watir::RadioGroup
    browser.radio_groups[1].values.should == ["hotdog", "burger", "tofu"]
    browser.radio_groups[2].name.should == 'fooda'
  end
  
  it 'if radio group does not exists it returns size 0 or name nil (or should it blow up? or respond to exists? method' do
    browser.radio_groups[6].size.should == 0 # does not exist. let's not blow up. suggestions?
    browser.radio_groups[6].name.should == nil #suggestions?
  end
  
  it 'groups contained by a form element' do
    browser.forms[1].radio_groups.length.should == 1
    names =[]
    browser.forms[1].radio_groups.each do |rg|
      names << rg.name
    end 
    names.should == ['food']
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
marekj-watirloo-0.0.5 spec/radio_groups_spec.rb
watirloo-0.0.8 spec/radio_groups_spec.rb
watirloo-0.0.7 spec/radio_groups_spec.rb