marekj-watirloo 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +12 -0
- data/Manifest.txt +59 -34
- data/README.rdoc +63 -80
- data/Rakefile.rb +32 -39
- data/config/locker.yml +0 -0
- data/lib/watirloo.rb +9 -162
- data/lib/watirloo/browsers.rb +73 -0
- data/lib/watirloo/desktop.rb +44 -0
- data/lib/watirloo/{firewatir_ducktape.rb → extension/firewatir_ducktape.rb} +0 -0
- data/lib/watirloo/extension/object.rb +26 -0
- data/lib/watirloo/{watir_ducktape.rb → extension/watir_ducktape.rb} +181 -16
- data/lib/watirloo/extension/watir_reflector.rb +83 -0
- data/lib/watirloo/locker.rb +84 -0
- data/lib/watirloo/page.rb +105 -0
- data/spec/browser_spec.rb +38 -0
- data/spec/browser_threads_spec.rb +45 -0
- data/spec/checkbox_group_spec.rb +136 -0
- data/spec/checkbox_groups_spec.rb +55 -0
- data/spec/checkboxes_value_spec.rb +35 -0
- data/spec/desktop_spec.rb +54 -0
- data/spec/extra/browser_events_spec.rb +76 -0
- data/spec/extra/page_objects_metrics.rb +139 -0
- data/spec/face_mixing_spec.rb +55 -0
- data/{test → spec}/firewatir/attach_instance_test.rb +0 -0
- data/spec/firewatir/spec_results.html +263 -0
- data/spec/firewatir/spec_results.txt +23 -0
- data/spec/firewatir/spec_results_failed.txt +3 -0
- data/{test → spec}/html/census.html +0 -0
- data/spec/html/checkbox_group1.html +33 -0
- data/spec/html/labels.html +53 -0
- data/spec/html/no_title.html +13 -0
- data/{test → spec}/html/person.html +0 -0
- data/spec/html/radio_group.html +35 -0
- data/{test → spec}/html/select_lists.html +0 -0
- data/spec/input_element_spec.rb +51 -0
- data/spec/label_spec.rb +65 -0
- data/spec/locker_spec.rb +49 -0
- data/spec/page_spec.rb +53 -0
- data/spec/person_def_wrappers_spec.rb +40 -0
- data/spec/radio_group_spec.rb +95 -0
- data/spec/radio_groups_spec.rb +55 -0
- data/spec/reflector_spec.rb +82 -0
- data/spec/select_list_options_spec.rb +40 -0
- data/spec/select_lists_spec.rb +151 -0
- data/{test/test_helper.rb → spec/spec_helper.rb} +6 -4
- data/spec/spec_helper_ff.rb +5 -0
- data/spec/spec_helper_runner.rb +13 -0
- data/spec/spec_results.html +566 -0
- data/spec/spec_results.txt +179 -0
- data/spec/spec_results_failed.txt +1 -0
- data/spec/text_fields_spec.rb +56 -0
- data/watirloo.gemspec +44 -44
- metadata +80 -39
- data/lib/watirloo/reflector.rb +0 -137
- data/test/checkbox_group_test.rb +0 -83
- data/test/checkboxes_value_test.rb +0 -50
- data/test/html/checkbox_group1.html +0 -20
- data/test/html/labels.html +0 -32
- data/test/html/radio_group.html +0 -41
- data/test/interfaces_test.rb +0 -79
- data/test/label_test.rb +0 -64
- data/test/person_def_wrappers_test.rb +0 -55
- data/test/radio_group_test.rb +0 -97
- data/test/select_list_in_class_test.rb +0 -39
- data/test/select_list_options_test.rb +0 -39
- data/test/select_lists_test.rb +0 -145
- data/test/text_fields_test.rb +0 -68
data/test/label_test.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
describe 'label wrapping text field' do
|
3
|
-
|
4
|
-
before do
|
5
|
-
@page = Watirloo::Page.new
|
6
|
-
@page.browser.goto testfile('labels.html')
|
7
|
-
@page.face(
|
8
|
-
:first => [:text_field, :name, 'fn'],
|
9
|
-
:last => [:text_field, :name, 'ln']
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'accessed by parent should be Watir Element' do
|
14
|
-
if @page.b.kind_of?(FireWatir::Firefox)
|
15
|
-
@page.first.parent.kind_of?(String).should == true
|
16
|
-
@page.last.parent.kind_of?(String).should == true
|
17
|
-
flunk('FIXME Firefox returns String for parent and not Element')
|
18
|
-
|
19
|
-
elsif @page.b.kind_of?(Watir::IE)
|
20
|
-
@page.first.parent.kind_of?(Watir::Element).should == true
|
21
|
-
@page.last.parent.kind_of?(Watir::Element).should == true
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'accessed by parent tagName should be a LABEL' do
|
27
|
-
if @page.b.kind_of?(Watir::IE)
|
28
|
-
@page.first.parent.document.tagName.should == "LABEL"
|
29
|
-
@page.last.parent.document.tagName.should == "LABEL"
|
30
|
-
elsif @page.b.kind_of?(FireWatir::Firefox)
|
31
|
-
flunk('FIXME Firefox returns String for parent and not Element')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'accessed by parent text returns text of label' do
|
36
|
-
if @page.b.kind_of?(Watir::IE)
|
37
|
-
@page.first.parent.text.should == 'First Name'
|
38
|
-
@page.last.parent.text.should == 'Last Name'
|
39
|
-
|
40
|
-
elsif @page.b.kind_of?(FireWatir::Firefox)
|
41
|
-
flunk('FIXME Firefox returns String for parent and not Element.')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'label for text field' do
|
47
|
-
before do
|
48
|
-
@page = Watirloo::Page.new
|
49
|
-
@page.goto testfile('labels.html')
|
50
|
-
@page.face(
|
51
|
-
:first => [:text_field, :id, 'first_nm'],
|
52
|
-
:last => [:text_field, :id, 'last_nm'],
|
53
|
-
:first_label => [:label, :for, 'first_nm'],
|
54
|
-
:last_label => [:label, :for, 'last_nm']
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'value of label' do
|
59
|
-
@page.first_label.text.should == 'FirstName For'
|
60
|
-
@page.last_label.text.should == 'LastName For'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
# There are 3 ways of defining an interface
|
4
|
-
# 1. class level face hash definition
|
5
|
-
# 2 def semanticname wrapper created for element
|
6
|
-
# 3 or just delegate to the browsing with familiar watir api
|
7
|
-
class Person < Watirloo::Page
|
8
|
-
|
9
|
-
# class level interfaces as definitions for Browser
|
10
|
-
face :first => [:text_field, :name, 'first_nm']
|
11
|
-
face :street => [:text_field, :name, 'addr1']
|
12
|
-
|
13
|
-
# def wrapper with suggested semantic name returns dom element
|
14
|
-
# these wrappers can provide specialized behavior on the page
|
15
|
-
def last
|
16
|
-
@b.text_field(:name, 'last_nm')
|
17
|
-
end
|
18
|
-
|
19
|
-
def dob
|
20
|
-
@b.text_field(:name, 'dob')
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
describe "Person Page interfaces defined by def wrappers and class definitions" do
|
27
|
-
|
28
|
-
before :each do
|
29
|
-
@page = Person.new
|
30
|
-
@page.browser.goto testfile('person.html')
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'calling face when there is wrapper method' do
|
34
|
-
@page.last.set 'Wonkatonka'
|
35
|
-
@page.last.value.should == 'Wonkatonka'
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'calling interface when there is definition and no method' do
|
39
|
-
@page.first.set 'Oompaloompa'
|
40
|
-
@page.first.value.should == 'Oompaloompa'
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'delegating to browser when there is no definition' do
|
44
|
-
@page.select_list(:name, 'sex_cd').set 'F'
|
45
|
-
@page.select_list(:name, 'sex_cd').selected.should == 'F'
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'spray method by convetion has keys correspondig to interface names for watir elements' do
|
49
|
-
mapping = {:street => '13 Sad Enchiladas Lane', :dob => '02/03/1977'}
|
50
|
-
@page.spray mapping
|
51
|
-
@page.street.value.should == mapping[:street]
|
52
|
-
@page.dob.value.should == mapping[:dob]
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
data/test/radio_group_test.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
describe 'RadioGroup class access in watir browser' do
|
4
|
-
before :each do
|
5
|
-
@browser = Watirloo::Page.new.browser
|
6
|
-
@browser.goto testfile('radio_group.html')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'browser responds to radio_group' do
|
10
|
-
@browser.respond_to?(:radio_group).should == true
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'finds radio group on the page' do
|
14
|
-
rg = @browser.radio_group('food')
|
15
|
-
rg.size.should == 3
|
16
|
-
rg.values.should == %w[hotdog burger tofu]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
describe 'RadioGroup class interface in watirloo' do
|
22
|
-
|
23
|
-
class RadioGroupPage < Watirloo::Page
|
24
|
-
face :meals_to_go => [:radio_group, 'food']
|
25
|
-
end
|
26
|
-
|
27
|
-
before do
|
28
|
-
@page = RadioGroupPage.new
|
29
|
-
@page.browser.goto testfile('radio_group.html')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'container radio_group method returns RadioGroup class' do
|
33
|
-
# verify browser namespace explicitly
|
34
|
-
if @page.b.kind_of?(FireWatir::Firefox)
|
35
|
-
@page.meals_to_go.kind_of?(FireWatir::RadioGroup).should.be true
|
36
|
-
|
37
|
-
elsif @page.b.kind_of?(Watir::IE)
|
38
|
-
@page.meals_to_go.kind_of?(Watir::RadioGroup).should.be true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'size or count returns how many radios in a group' do
|
43
|
-
@page.meals_to_go.size.should == 3
|
44
|
-
@page.meals_to_go.count.should == 3
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'values returns value attributes text items as an array' do
|
48
|
-
@page.meals_to_go.values.should == ["hotdog", "burger", "tofu"]
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'selected_value returns internal option value for selected radio item in a group' do
|
52
|
-
@page.meals_to_go.selected.should == 'burger'
|
53
|
-
@page.meals_to_go.selected_value.should == 'burger'
|
54
|
-
@page.meals_to_go.selected_values.should == ['burger'] # matches select_list api
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'set selects radio by position in a group' do
|
58
|
-
@page.meals_to_go.set 3
|
59
|
-
@page.meals_to_go.selected.should == 'tofu'
|
60
|
-
@page.meals_to_go.selected_value.should == 'tofu'
|
61
|
-
@page.meals_to_go.selected_values.should == ['tofu']
|
62
|
-
|
63
|
-
@page.meals_to_go.set 1
|
64
|
-
@page.meals_to_go.selected.should == 'hotdog'
|
65
|
-
@page.meals_to_go.selected_value.should == 'hotdog'
|
66
|
-
@page.meals_to_go.selected_values.should == ['hotdog']
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'set selects radio by value in a group' do
|
70
|
-
@page.meals_to_go.set 'hotdog'
|
71
|
-
@page.meals_to_go.selected.should == 'hotdog'
|
72
|
-
|
73
|
-
@page.meals_to_go.set 'tofu'
|
74
|
-
@page.meals_to_go.selected_value.should == 'tofu'
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'set position throws exception if number not within the range of group size' do
|
78
|
-
assert_raise(Watir::Exception::WatirException) do
|
79
|
-
@page.meals_to_go.set 7
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'set value throws exception if value not found in options' do
|
84
|
-
assert_raise(Watir::Exception::WatirException) do
|
85
|
-
@page.meals_to_go.set 'banannnanna'
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# TODO do I want to provide mapping of human generated semantic values for radios
|
90
|
-
# to actual values here in the radio_group or at the Watirllo level only?
|
91
|
-
it 'set throws exception if other than Fixnum or String element is used' do
|
92
|
-
assert_raise(Watir::Exception::WatirException)do
|
93
|
-
@page.meals_to_go.set :yes
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
describe "select lists defining in class, instance and subclass" do
|
4
|
-
|
5
|
-
class SelectListPage < Watirloo::Page
|
6
|
-
face :pets => [:select_list, :name, 'animals']
|
7
|
-
end
|
8
|
-
|
9
|
-
before do
|
10
|
-
@page = SelectListPage.new
|
11
|
-
@page.face :gender => [:select_list, :name, 'sex_cd']
|
12
|
-
@page.browser.goto testfile('select_lists.html')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'face method with key parameter to construct SelectList per browser implementation' do
|
16
|
-
if @page.browser.kind_of?(FireWatir::Firefox)
|
17
|
-
@page.pets.kind_of?(FireWatir::SelectList).should == true
|
18
|
-
@page.gender.kind_of?(FireWatir::SelectList).should == true
|
19
|
-
|
20
|
-
elsif @page.browser.kind_of? Watir::IE
|
21
|
-
@page.pets.kind_of?(Watir::SelectList).should == true
|
22
|
-
@page.gender.kind_of?(Watir::SelectList).should == true
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'face(:facename) and browser.select_list access the same control' do
|
27
|
-
@page.select_list(:name, 'sex_cd').values.should == @page.gender.values
|
28
|
-
@page.select_list(:name, 'animals').values.should == @page.pets.values
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'subclassing the page and adding new interface gets previous ' do
|
32
|
-
class SelectListSub < SelectListPage
|
33
|
-
face :toys => [:select_list, :name, 'bubel']
|
34
|
-
end
|
35
|
-
page = SelectListSub.new
|
36
|
-
page.interfaces.keys.should == [:toys, :pets]
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
describe "SelectList options as visible items and values as hidden to the user attributes" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@page = Watirloo::Page.new
|
7
|
-
@page.b.goto testfile('select_lists.html')
|
8
|
-
@page.face(
|
9
|
-
:pets => [:select_list, :name, 'animals'],
|
10
|
-
:gender => [:select_list, :name, 'sex_cd'],
|
11
|
-
:toys => [:select_list, :name, 'bubel'])
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'values of options by facename method' do
|
15
|
-
@page.gender.values.should == ['', 'm', 'f']
|
16
|
-
@page.pets.values.should == ['o1', 'o2', 'o3', 'o4', 'o5']
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'options with no value attribute' do
|
20
|
-
# in case of IE it will return all blanks
|
21
|
-
if @page.b.kind_of?(Watir::IE)
|
22
|
-
@page.toys.values.should == ["", "", "", "", ""]
|
23
|
-
elsif @page.b.kind_of?(FireWatir::Firefox)
|
24
|
-
@page.toys.values.should == ["", "foobel", "barbel", "bazbel", "chuchu"]
|
25
|
-
# for Firfox it returns actual items
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'items method returns visible contents as array of text items' do
|
30
|
-
@page.toys.items.should == ["", "foobel", "barbel", "bazbel", "chuchu"]
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'items returns visible text items as array' do
|
34
|
-
@page.pets.items.should == ['cat', 'dog', 'zook', 'zebra', 'wumpa']
|
35
|
-
@page.gender.items.should == ["", "M", "F"]
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
end
|
data/test/select_lists_test.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
# testing single select and multiselect controls
|
4
|
-
describe "SelectList selections" do
|
5
|
-
|
6
|
-
before do
|
7
|
-
@page = Watirloo::Page.new
|
8
|
-
@page.b.goto testfile('select_lists.html')
|
9
|
-
@page.face(
|
10
|
-
:pets => [:select_list, :name, 'animals'],
|
11
|
-
:gender => [:select_list, :name, 'sex_cd'])
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'selected returns preselected item in single select' do
|
15
|
-
@page.gender.selected.should == '' # in single select "" is preselected
|
16
|
-
@page.gender.selected_item.should == '' # in single select "" is preselected
|
17
|
-
@page.gender.selected_items.should == ['']
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'selected returns preselected item in single select' do
|
21
|
-
@page.gender.selected_value.should == '' # in single select "" is preselected
|
22
|
-
@page.gender.selected_values.should == ['']
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
it 'selected returns nil for none selected itesm in multi select' do
|
27
|
-
@page.pets.selected.should == nil # in multiselect noting is selected
|
28
|
-
@page.pets.selected_item.should == nil
|
29
|
-
@page.pets.selected_items.should == [] # as array
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'selected returns nil for none selected itesm in multi select' do
|
33
|
-
@page.pets.selected_value.should == nil
|
34
|
-
@page.pets.selected_values.should == [] # as array
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'set and query option by text for multiselect when none selected' do
|
38
|
-
@page.pets.set 'dog'
|
39
|
-
@page.pets.selected.should == 'dog' #multi select one item selected
|
40
|
-
@page.pets.selected_item.should == 'dog' #multi select one item selected
|
41
|
-
@page.pets.selected_items.should == ['dog']
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'set and query option by value for multiselect when none selected' do
|
45
|
-
@page.pets.set_value 'o2'
|
46
|
-
@page.pets.selected.should == 'dog' #multi select one item selected
|
47
|
-
@page.pets.selected_value.should == 'o2' #multi select one item selected
|
48
|
-
@page.pets.selected_values.should == ['o2']
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'set and query option by text for single select' do
|
52
|
-
@page.gender.set 'F'
|
53
|
-
@page.gender.selected.should == 'F' # single select one item
|
54
|
-
@page.gender.selected_item.should == 'F' # single select one item
|
55
|
-
@page.gender.selected_items.should == ['F'] # single select one item
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'set and query option by value for single select' do
|
59
|
-
@page.gender.set_value 'f'
|
60
|
-
@page.gender.selected.should == 'F'
|
61
|
-
@page.gender.selected_value.should == 'f' # single select one item
|
62
|
-
@page.gender.selected_values.should == ['f'] # single select one item
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
it 'set by text multple items for multiselect selects each item' do
|
67
|
-
@page.pets.set ['cat', 'dog']
|
68
|
-
@page.pets.selected.should == ['cat','dog']
|
69
|
-
@page.pets.selected_item.should == ['cat','dog'] # bypass filter when more than one item
|
70
|
-
@page.pets.selected_items.should == ['cat','dog']
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'set by value multple items for multiselect selects each item' do
|
74
|
-
@page.pets.set_value ['o1', 'o2']
|
75
|
-
@page.pets.selected.should == ['cat','dog']
|
76
|
-
@page.pets.selected_value.should == ['o1','o2'] # bypass filter when more than one item
|
77
|
-
@page.pets.selected_value.should == ['o1','o2']
|
78
|
-
end
|
79
|
-
|
80
|
-
# this is not practical for single select but can be done for testing
|
81
|
-
# conditions arising from switching items in a batch approach
|
82
|
-
it 'set items array for single select selects each in turn. selected is the last item in array' do
|
83
|
-
@page.gender.set ['M', 'F', '','F']
|
84
|
-
@page.gender.selected.should == 'F'
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'set item after multiple items were set returns all values selected for multiselect' do
|
88
|
-
@page.pets.set ['cat','zook']
|
89
|
-
@page.pets.set 'zebra'
|
90
|
-
@page.pets.selected.should == ['cat', 'zook', 'zebra']
|
91
|
-
@page.pets.selected_values.should == ['o1', 'o3', 'o4']
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'set using position for multiselect' do
|
95
|
-
@page.pets.set 3
|
96
|
-
@page.pets.selected.should == 'zook'
|
97
|
-
@page.pets.set_value 2 # translate to second text item
|
98
|
-
@page.pets.selected.should == ['dog', 'zook']
|
99
|
-
@page.pets.set [1,4,5]
|
100
|
-
@page.pets.selected.should == ['cat','dog','zook', 'zebra','wumpa']
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'set using position and item for multiselect' do
|
104
|
-
@page.pets.set [1,'zebra', 'zook', 2, 4] #select already selected
|
105
|
-
@page.pets.selected.should == ['cat','dog','zook','zebra']
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'set using position for single select' do
|
109
|
-
@page.gender.set 2
|
110
|
-
@page.gender.selected.should == 'M'
|
111
|
-
@page.gender.selected_value.should == 'm'
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'clear removes selected attribuet for all selected items in multiselect' do
|
115
|
-
@page.pets.selected.should == nil
|
116
|
-
@page.pets.set ['zook', 'cat']
|
117
|
-
@page.pets.selected.should == ['cat','zook']
|
118
|
-
@page.pets.clear
|
119
|
-
@page.pets.selected.should == nil
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'clear removes selected attribute for item in single select list' do
|
123
|
-
@page.gender.selected.should == ''
|
124
|
-
@page.gender.set 'F'
|
125
|
-
@page.gender.selected.should == 'F'
|
126
|
-
@page.gender.clear
|
127
|
-
@page.gender.selected.should.not == 'F' # This fails on IE. it does not remove selected attribute from options
|
128
|
-
# FIXME I think this is bug in Watir clearSelection method but only on ie
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'set_value selects value atribute text' do
|
132
|
-
@page.gender.set_value 'm'
|
133
|
-
@page.gender.selected.should == 'M'
|
134
|
-
@page.gender.selected_value.should == 'm' #when you know there is only one item expected
|
135
|
-
@page.gender.selected_values.should == ['m'] # array of items
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'set_value for multiselect returns selected and selected_values' do
|
139
|
-
@page.pets.set_value 'o2'
|
140
|
-
@page.pets.set_value 'o4'
|
141
|
-
@page.pets.selected.should == ['dog', 'zebra']
|
142
|
-
@page.pets.selected_value.should == ['o2', 'o4'] # if array then bypass filter
|
143
|
-
@page.pets.selected_values.should == ['o2', 'o4'] # plural
|
144
|
-
end
|
145
|
-
end
|
data/test/text_fields_test.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
describe "add faces text fields page objects" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@page = Watirloo::Page.new
|
7
|
-
@page.b.goto testfile('person.html')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'interfaces initially is an empty Hash' do
|
11
|
-
@page.interfaces.should == {}
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'instance method face accepts keys as semantic faces and values as definitions to construct Watir Elements' do
|
15
|
-
@page.face(
|
16
|
-
:last => [:text_field, :name, 'last_nm'],
|
17
|
-
:first => [:text_field, :name, 'first_nm'])
|
18
|
-
@page.interfaces.size.should == 2
|
19
|
-
|
20
|
-
if @page.browser.kind_of? FireWatir::Firefox
|
21
|
-
@page.first.kind_of?(FireWatir::TextField).should == true
|
22
|
-
@page.last.kind_of?(FireWatir::TextField).should == true
|
23
|
-
|
24
|
-
elsif @page.b.kind_of? Watir::IE
|
25
|
-
@page.first.kind_of?(Watir::TextField).should == true
|
26
|
-
@page.last.kind_of?(Watir::TextField).should == true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "text fields page objects setting and getting values" do
|
32
|
-
|
33
|
-
before do
|
34
|
-
@page = Watirloo::Page.new
|
35
|
-
@page.goto testfile('person.html')
|
36
|
-
@page.face(
|
37
|
-
:last => [:text_field, :name, 'last_nm'],
|
38
|
-
:first => [:text_field, :name, 'first_nm']
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'face name method and value returns current text' do
|
43
|
-
@page.first.value.should == 'Joanney'
|
44
|
-
@page.last.value.should == 'Begoodnuffski'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "face name method and set enters value into field" do
|
48
|
-
params = {:first => 'Grzegorz',:last => 'Brzeczyszczykiewicz'}
|
49
|
-
@page.first.set params[:first]
|
50
|
-
@page.last.set params[:last]
|
51
|
-
@page.first.value.should == params[:first]
|
52
|
-
@page.last.value.should == params[:last]
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'spray method matches keys to semantic values and sets values' do
|
56
|
-
params = {:first => 'Grzegorz',:last => 'Brzeczyszczykiewicz'}
|
57
|
-
@page.spray params
|
58
|
-
@page.first.value.should == params[:first]
|
59
|
-
@page.last.value.should == params[:last]
|
60
|
-
|
61
|
-
end
|
62
|
-
it 'spray values match semantic keys to faces and set their values' do
|
63
|
-
@page.spray :first => 'Hermenegilda', :last => 'Kociubinska'
|
64
|
-
@page.first.value.should == 'Hermenegilda'
|
65
|
-
@page.last.value.should == 'Kociubinska'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|