marekj-watirloo 0.0.2

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.
@@ -0,0 +1,44 @@
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.add_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 face(:facename) method' do
15
+ @page.face(:gender).values.should == ['', 'm', 'f']
16
+ @page.face(:pets).values.should == ['o1', 'o2', 'o3', 'o4', 'o5']
17
+ end
18
+
19
+ it 'values of options by facename method' do
20
+ @page.gender.values.should == ['', 'm', 'f']
21
+ @page.pets.values.should == ['o1', 'o2', 'o3', 'o4', 'o5']
22
+ end
23
+
24
+ it 'options with no value attribute' do
25
+ # in case of IE it will return all blanks
26
+ if @page.b.kind_of?(Watir::IE)
27
+ @page.toys.values.should == ["", "", "", "", ""]
28
+ elsif @page.b.kind_of?(FireWatir::Firefox)
29
+ @page.toys.values.should == ["", "foobel", "barbel", "bazbel", "chuchu"]
30
+ # for Firfox it returns actual items
31
+ end
32
+ end
33
+
34
+ it 'options method returns visible contents as array of text items' do
35
+ @page.toys.items.should == ["", "foobel", "barbel", "bazbel", "chuchu"]
36
+ end
37
+
38
+ it 'options returns visible text items as array' do
39
+ @page.pets.items.should == ['cat', 'dog', 'zook', 'zebra', 'wumpa']
40
+ @page.gender.items.should == ["", "M", "F"]
41
+ end
42
+
43
+
44
+ end
@@ -0,0 +1,145 @@
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.add_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
@@ -0,0 +1,9 @@
1
+ require 'stringio'
2
+ require 'test/spec'
3
+ require File.dirname(__FILE__) + '/../lib/watirloo'
4
+ #Watirloo::BrowserHerd.target = :firefox
5
+ def testfile(filename)
6
+ path = File.expand_path(File.dirname(__FILE__))
7
+ uri = "file://#{path}/html/" + filename
8
+ return uri
9
+ end
@@ -0,0 +1,74 @@
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 'faces initially is an empty Hash' do
11
+ @page.faces.should == {}
12
+ end
13
+
14
+ it 'add_face accepts keys as semantic faces and values as definitions to construct Watir Elements' do
15
+ @page.add_face(
16
+ :last => [:text_field, :name, 'last_nm'],
17
+ :first => [:text_field, :name, 'first_nm'])
18
+ @page.faces.size.should == 2
19
+ #TODO TextField should be Watir and independent of Browser IE, FireFox or others.
20
+ if @page.b.kind_of? FireWatir::Firefox
21
+ @page.face(:first).kind_of?(FireWatir::TextField).should == true
22
+ @page.face(:last).kind_of?(FireWatir::TextField).should == true
23
+
24
+ elsif @page.b.kind_of? Watir::IE
25
+ @page.face(:first).kind_of?(Watir::TextField).should == true
26
+ @page.face(: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.add_face(
37
+ :last => [:text_field, :name, 'last_nm'],
38
+ :first => [:text_field, :name, 'first_nm']
39
+ )
40
+ end
41
+
42
+ it "face name keyword and value returns current text" do
43
+ @page.face(:first).value.should == 'Joanney'
44
+ @page.face(:last).value.should == 'Begoodnuffski'
45
+ end
46
+
47
+ it 'face name method and value returns current text' do
48
+ @page.first.value.should == 'Joanney'
49
+ @page.last.value.should == 'Begoodnuffski'
50
+ end
51
+
52
+ it "face name kewords and set enters value into field" do
53
+ params = {:first => 'Grzegorz',:last => 'Brzeczyszczykiewicz'}
54
+ @page.face(:first).set params[:first]
55
+ @page.face(:last).set params[:last]
56
+ @page.face(:first).value.should == params[:first]
57
+ @page.face(:last).value.should == params[:last]
58
+ end
59
+
60
+ it "face name method and set enters value into field" do
61
+ params = {:first => 'Grzegorz',:last => 'Brzeczyszczykiewicz'}
62
+ @page.first.set params[:first]
63
+ @page.last.set params[:last]
64
+ @page.first.value.should == params[:first]
65
+ @page.last.value.should == params[:last]
66
+ end
67
+
68
+ it 'spray values match semantic keys to faces and set their values' do
69
+ @page.spray :first => 'Hermenegilda', :last => 'Kociubinska'
70
+ @page.face(:first).value.should == 'Hermenegilda'
71
+ @page.face(:last).value.should == 'Kociubinska'
72
+ end
73
+ end
74
+
data/watirloo.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{watirloo}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["marekj"]
9
+ s.date = %q{2009-01-07}
10
+ s.description = %q{Watir Framework and Helper based on Semantic Page Objects Modeling. Helps you design tests expressing DOM elements and groups of elements on the page as Semantic Page Objects rather than their DOM implementations. It is not a DSL but it helps you write human readable tests and hooks them up to Watir browsers for implementation Give it a try. You will like it.}
11
+ s.email = ["marekj.com@gmail.com"]
12
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
13
+ s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile.rb", "lib/watirloo", "lib/watirloo.rb", "lib/watirloo/firewatir_ducktape.rb", "lib/watirloo/reflector.rb", "lib/watirloo/watir_ducktape.rb", "script/console", "script/console.cmd", "script/destroy", "script/destroy.cmd", "script/generate", "script/generate.cmd", "script/reflect.rb", "test/checkbox_group_test.rb", "test/checkboxes_value_test.rb", "test/firewatir", "test/firewatir/attach_instance_test.rb", "test/html", "test/html/census.html", "test/html/checkbox_group1.html", "test/html/labels.html", "test/html/person.html", "test/html/radio_group.html", "test/html/select_lists.html", "test/label_test.rb", "test/person_def_wrappers_test.rb", "test/radio_group_test.rb", "test/select_list_as_face_test.rb", "test/select_list_options_test.rb", "test/select_lists_test.rb", "test/test_helper.rb", "test/text_fields_test.rb", "watirloo.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://watirloo.testr.us}
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{watirloo}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Watir Framework and Helper based on Semantic Page Objects Modeling}
21
+ s.test_files = ["test/checkboxes_value_test.rb", "test/checkbox_group_test.rb", "test/label_test.rb", "test/person_def_wrappers_test.rb", "test/radio_group_test.rb", "test/select_lists_test.rb", "test/select_list_as_face_test.rb", "test/select_list_options_test.rb", "test/text_fields_test.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<watir>, [">= 1.6.2"])
29
+ s.add_development_dependency(%q<newgem>, [">= 1.2.1"])
30
+ s.add_development_dependency(%q<test/spec>, [">= 0.9.0"])
31
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
32
+ else
33
+ s.add_dependency(%q<watir>, [">= 1.6.2"])
34
+ s.add_dependency(%q<newgem>, [">= 1.2.1"])
35
+ s.add_dependency(%q<test/spec>, [">= 0.9.0"])
36
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
37
+ end
38
+ else
39
+ s.add_dependency(%q<watir>, [">= 1.6.2"])
40
+ s.add_dependency(%q<newgem>, [">= 1.2.1"])
41
+ s.add_dependency(%q<test/spec>, [">= 0.9.0"])
42
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marekj-watirloo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - marekj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-07 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: watir
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.6.2
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: newgem
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.2.1
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: test/spec
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.0
41
+ version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: hoe
44
+ version_requirement:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.8.0
50
+ version:
51
+ description: Watir Framework and Helper based on Semantic Page Objects Modeling. Helps you design tests expressing DOM elements and groups of elements on the page as Semantic Page Objects rather than their DOM implementations. It is not a DSL but it helps you write human readable tests and hooks them up to Watir browsers for implementation Give it a try. You will like it.
52
+ email:
53
+ - marekj.com@gmail.com
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ extra_rdoc_files:
59
+ - History.txt
60
+ - Manifest.txt
61
+ - README.rdoc
62
+ files:
63
+ - History.txt
64
+ - Manifest.txt
65
+ - README.rdoc
66
+ - Rakefile.rb
67
+ - lib/watirloo
68
+ - lib/watirloo.rb
69
+ - lib/watirloo/firewatir_ducktape.rb
70
+ - lib/watirloo/reflector.rb
71
+ - lib/watirloo/watir_ducktape.rb
72
+ - script/console
73
+ - script/console.cmd
74
+ - script/destroy
75
+ - script/destroy.cmd
76
+ - script/generate
77
+ - script/generate.cmd
78
+ - script/reflect.rb
79
+ - test/checkbox_group_test.rb
80
+ - test/checkboxes_value_test.rb
81
+ - test/firewatir
82
+ - test/firewatir/attach_instance_test.rb
83
+ - test/html
84
+ - test/html/census.html
85
+ - test/html/checkbox_group1.html
86
+ - test/html/labels.html
87
+ - test/html/person.html
88
+ - test/html/radio_group.html
89
+ - test/html/select_lists.html
90
+ - test/label_test.rb
91
+ - test/person_def_wrappers_test.rb
92
+ - test/radio_group_test.rb
93
+ - test/select_list_as_face_test.rb
94
+ - test/select_list_options_test.rb
95
+ - test/select_lists_test.rb
96
+ - test/test_helper.rb
97
+ - test/text_fields_test.rb
98
+ - watirloo.gemspec
99
+ has_rdoc: true
100
+ homepage: http://watirloo.testr.us
101
+ post_install_message:
102
+ rdoc_options:
103
+ - --main
104
+ - README.rdoc
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ version:
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ version:
119
+ requirements: []
120
+
121
+ rubyforge_project: watirloo
122
+ rubygems_version: 1.2.0
123
+ signing_key:
124
+ specification_version: 2
125
+ summary: Watir Framework and Helper based on Semantic Page Objects Modeling
126
+ test_files:
127
+ - test/checkboxes_value_test.rb
128
+ - test/checkbox_group_test.rb
129
+ - test/label_test.rb
130
+ - test/person_def_wrappers_test.rb
131
+ - test/radio_group_test.rb
132
+ - test/select_lists_test.rb
133
+ - test/select_list_as_face_test.rb
134
+ - test/select_list_options_test.rb
135
+ - test/text_fields_test.rb