marekj-watirloo 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
text field wrapped in label tag without for attribute defined
|
3
|
+
- parent of text_field should be Watir Element (FAILED - 1)
|
4
|
+
- parent tagName should be a LABEL (FAILED - 2)
|
5
|
+
- parent text returns text of label (FAILED - 3)
|
6
|
+
|
7
|
+
label for text field not wrapped
|
8
|
+
- text value of label
|
9
|
+
|
10
|
+
SelectList selections
|
11
|
+
- selected returns preselected item in single select
|
12
|
+
- selected returns preselected value in single select
|
13
|
+
- selected returns nil for none selected items in multi select
|
14
|
+
- selected returns nil for none selected values in multi select
|
15
|
+
- set item text and find selected item and text for multiselect
|
16
|
+
- set value and find selected item and value for multiselect
|
17
|
+
- set and query option by text for single select
|
18
|
+
- set and query option by value for single select
|
19
|
+
- set by text multple items for multiselect selects each item
|
20
|
+
- set by value multple items for multiselect selects each item
|
21
|
+
- set items array for single select selects each in turn. selected is the last item in array
|
22
|
+
- set item after multiple items were set returns all values selected for multiselect
|
23
|
+
- set using position for multiselect
|
@@ -0,0 +1,3 @@
|
|
1
|
+
text field wrapped in label tag without for attribute defined parent of text_field should be Watir Element
|
2
|
+
text field wrapped in label tag without for attribute defined parent tagName should be a LABEL
|
3
|
+
text field wrapped in label tag without for attribute defined parent text returns text of label
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!--
|
2
|
+
Document : checbox_group
|
3
|
+
-->
|
4
|
+
<!DOCtype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<title></title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<form name="forma">
|
12
|
+
<h3>Pets CheckboxGroup. Each has value. Acts like MultiSelectList. none, one ore more items can be checked.</h3>
|
13
|
+
<input name="pets" type="checkbox" value="cat">Cat<br />
|
14
|
+
<input name="pets" type="checkbox" value="dog">Dog<br />
|
15
|
+
<input name="pets" type="checkbox" value="zook">Zook<br />
|
16
|
+
<input name="pets" type="checkbox" value="zebra">Zebra<br />
|
17
|
+
<input name="pets" type="checkbox" value="wumpa">Wumpa<br />
|
18
|
+
<h3>Single CheckboxToggle Only. Acts like RadioGroup on/off switch.</h3>
|
19
|
+
<input name="singleIndicator" type="checkbox">Toggle Me<br />
|
20
|
+
</form>
|
21
|
+
<form name="formb">
|
22
|
+
<h3>Petsa (with last names) CheckboxGroup. Each has value. Acts like MultiSelectList. none, one ore more items can be checked.</h3>
|
23
|
+
<input name="petsa" type="checkbox" value="cata">Cat Mleczus<br />
|
24
|
+
<input name="petsa" type="checkbox" value="doga">Dog Wuffski<br />
|
25
|
+
<input name="petsa" type="checkbox" value="zooka">Zook ZookaZeeka<br />
|
26
|
+
<input name="petsa" type="checkbox" value="zebraa">Zebra Pregowana<br />
|
27
|
+
<input name="petsa" type="checkbox" value="wumpaa">Wumpa OompaPlumpa<br />
|
28
|
+
<h3>Single CheckboxToggle Only. Acts like RadioGroup on/off switch.</h3>
|
29
|
+
<input name="singleIndicatora" type="checkbox">Toggle Me Me<br />
|
30
|
+
</form>
|
31
|
+
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<!--
|
2
|
+
Document : labels
|
3
|
+
http://www.w3.org/TR/html401/interact/forms.html#edef-LABEL
|
4
|
+
-->
|
5
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>Labels</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h3> About Labels </h3>
|
13
|
+
<p><a href="http://www.w3.org/TR/html401/interact/forms.html#edef-LABEL">html401 label spec</a> --
|
14
|
+
label atribute :for holds a value of element :id it is bound to. Click on label sets the element with specified :id
|
15
|
+
<br />
|
16
|
+
checkbox, text_field, radiobutton do not have explicit labels like buttons
|
17
|
+
</p>
|
18
|
+
|
19
|
+
<h3>Implicit label wraps text_field without for attribute. Click does not transfer focus to control</h3>
|
20
|
+
<p>not a standard usage for label</p>
|
21
|
+
<form id="wrap_without_for"action="" method="get">
|
22
|
+
<p>
|
23
|
+
<label>First Name<input type="text" name="fn"></label>
|
24
|
+
</p>
|
25
|
+
<p>
|
26
|
+
<label><input type="text" name="ln">Last Name</label>
|
27
|
+
</p>
|
28
|
+
</form>
|
29
|
+
|
30
|
+
<h3>Explicit Label For Item with Id. Click transfers focus to control associated by id</h3>
|
31
|
+
<form id="label_for_id"action="" method="get">
|
32
|
+
<p>
|
33
|
+
<label for="first_nm">FirstName For</label>
|
34
|
+
<input type="text" name="firstname" id="first_nm">
|
35
|
+
|
36
|
+
<label for="last_nm">LastName For</label>
|
37
|
+
<input type="text" name="lastname" id="last_nm">
|
38
|
+
|
39
|
+
<br />
|
40
|
+
|
41
|
+
<label for="gender_code">Select Gender</label>
|
42
|
+
<select name="sex_cd" id="gender_code">
|
43
|
+
<option value="" selected></option>
|
44
|
+
<option value="M">Male</option>
|
45
|
+
<option value="F">Female</option>
|
46
|
+
</select>
|
47
|
+
|
48
|
+
|
49
|
+
</p>
|
50
|
+
</form>
|
51
|
+
|
52
|
+
</body>
|
53
|
+
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!--
|
2
|
+
no title set for window
|
3
|
+
-->
|
4
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<title></title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="notitle">THIS IE HAS NO TITLE</div>
|
12
|
+
</body>
|
13
|
+
</html>
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<!-- Document : radio_group --> <!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.01 Transitional//EN">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>radio_groups</title>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html;
|
6
|
+
charset=UTF-8"> </head>
|
7
|
+
<body>
|
8
|
+
<h3>wanna eat what?</h3>
|
9
|
+
<form name="radios2" action="/"> <table border="0">
|
10
|
+
<tbody>
|
11
|
+
<tr><td><input type="radio" name="food" value="hotdog" /></td><td>Hothund</td></tr>
|
12
|
+
<tr><td><input type="radio" name="food" value="burger" checked /></td><td>Burgier</td></tr>
|
13
|
+
<tr><td><input type="radio" name="food" value="tofu" /></td><td>Tofoo</td></tr>
|
14
|
+
</tbody></table>
|
15
|
+
</form>
|
16
|
+
<h3>wannaa eata whata?</h3>
|
17
|
+
<form name="radios3" action="/"> <table border="0">
|
18
|
+
<tbody>
|
19
|
+
<tr><td><input type="radio" name="fooda" value="hotdoga" /></td><td>Hothunda</td></tr>
|
20
|
+
<tr><td><input type="radio" name="fooda" value="burgera" /></td><td>Burgiera</td></tr>
|
21
|
+
<tr><td><input type="radio" name="fooda" value="tofua" checked/></td><td>Tofooa</td></tr>
|
22
|
+
</tbody></table>
|
23
|
+
</form>
|
24
|
+
|
25
|
+
<h3>fooda same name but scoped to diff form name</h3>
|
26
|
+
<form name="radios4" action="/"> <table border="0">
|
27
|
+
<tbody>
|
28
|
+
<tr><td><input type="radio" name="fooda" value="hotdoga_t" /></td><td>Hothunda_t</td></tr>
|
29
|
+
<tr><td><input type="radio" name="fooda" value="burgera_t" /></td><td>Burgiera_t</td></tr>
|
30
|
+
<tr><td><input type="radio" name="fooda" value="tofua_t" checked/></td><td>Tofooa_t</td></tr>
|
31
|
+
</tbody></table>
|
32
|
+
</form>
|
33
|
+
|
34
|
+
</body>
|
35
|
+
</html>
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
module Watir
|
4
|
+
module Container
|
5
|
+
|
6
|
+
def input_label(label)
|
7
|
+
what = self.label(:text, label).for
|
8
|
+
raise "label for attribute is blank" if what == ""
|
9
|
+
input_id(what)
|
10
|
+
end
|
11
|
+
|
12
|
+
# If user knowns the Label that has a for attribute pointing to an element we can access that element by
|
13
|
+
# input_element(:lable, 'Text Of Label')
|
14
|
+
def input_id(what)
|
15
|
+
raise "provide a String for Id" unless what.kind_of?(String)
|
16
|
+
# for input_element('bla') convention to (:id,'bla')
|
17
|
+
mystery_element = self.document.getElementById(what)
|
18
|
+
raise 'Element not found' unless mystery_element
|
19
|
+
mystery_type = mystery_element.invoke('type')
|
20
|
+
return text_field(:id, what) if TextField::INPUT_TYPES.include? mystery_type
|
21
|
+
return select_list(:id, what) if SelectList::INPUT_TYPES.include? mystery_type
|
22
|
+
# TODO working on this
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'Mystery input element' do
|
29
|
+
|
30
|
+
include Watirloo::Page
|
31
|
+
|
32
|
+
before do
|
33
|
+
browser.goto testfile('labels.html')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'the id is text_field' do
|
37
|
+
browser.input_id('first_nm').should be_kind_of(Watir::TextField)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'the label points to text_field' do
|
41
|
+
browser.input_label('FirstName For').should be_kind_of(Watir::TextField)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "the id should return select_list" do
|
45
|
+
browser.input_id('gender_code').should be_kind_of(Watir::SelectList)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
data/spec/label_spec.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'text field wrapped in label tag without for attribute defined' do
|
5
|
+
|
6
|
+
include Watirloo::Page
|
7
|
+
face(:first) { doc.text_field(:name, 'fn') }
|
8
|
+
face(:last) { doc.text_field(:name, 'ln') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
browser.goto testfile('labels.html')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'parent of text_field should be Watir Element' do
|
15
|
+
if browser.kind_of?(FireWatir::Firefox)
|
16
|
+
first.parent.should be_kind_of(String)
|
17
|
+
last.parent.should be_kind_of?(String)
|
18
|
+
flunk('FIXME Firefox returns String for parent and not Element')
|
19
|
+
|
20
|
+
elsif browser.kind_of?(Watir::IE)
|
21
|
+
first.parent.should be_kind_of(Watir::Element)
|
22
|
+
last.parent.should be_kind_of(Watir::Element)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'parent tagName should be a LABEL' do
|
28
|
+
if browser.kind_of?(Watir::IE)
|
29
|
+
first.parent.document.tagName.should == "LABEL"
|
30
|
+
last.parent.document.tagName.should == "LABEL"
|
31
|
+
|
32
|
+
elsif browser.kind_of?(FireWatir::Firefox)
|
33
|
+
flunk('FIXME Firefox returns String for parent and not Element')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'parent text returns text of label' do
|
38
|
+
if browser.kind_of?(Watir::IE)
|
39
|
+
first.parent.text.should == 'First Name'
|
40
|
+
last.parent.text.should == 'Last Name'
|
41
|
+
|
42
|
+
elsif browser.kind_of?(FireWatir::Firefox)
|
43
|
+
flunk('FIXME Firefox returns String for parent and not Element.')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
describe 'label for text field not wrapped' do
|
51
|
+
|
52
|
+
# reopen the class and add more interfaces
|
53
|
+
include Watirloo::Page
|
54
|
+
face(:first_label) { doc.label(:for, 'first_nm') }
|
55
|
+
face(:last_label) { doc.label(:for, 'last_nm') }
|
56
|
+
|
57
|
+
before do
|
58
|
+
browser.goto testfile('labels.html')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'text value of label' do
|
62
|
+
first_label.text.should == 'FirstName For'
|
63
|
+
last_label.text.should == 'LastName For'
|
64
|
+
end
|
65
|
+
end
|
data/spec/locker_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "Locker" do
|
5
|
+
|
6
|
+
it "locker file does not exist. create it. mapping should return empty hash" do
|
7
|
+
Watirloo::Locker.mapping.clear
|
8
|
+
FileUtils.rm_f(Watirloo::Locker.locker) if FileTest.exist?(Watirloo::Locker.locker) #remove locker file
|
9
|
+
FileTest.exist?(Watirloo::Locker.locker).should be_false
|
10
|
+
Watirloo::Locker.mapping.should == {}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "clear should create locker file and save empty mapping" do
|
14
|
+
Watirloo::Locker.clear
|
15
|
+
FileTest.exist?(Watirloo::Locker.locker).should be_true
|
16
|
+
Watirloo::Locker.mapping.should == {}
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'add stores ie.hwnd with friendly name and adds it to mapping' do
|
20
|
+
ie = Watir::IE.new
|
21
|
+
Watirloo::Locker.add(ie, 'one')
|
22
|
+
Watirloo::Locker.add(ie, 'two')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'mapping holds what was added' do
|
26
|
+
Watirloo::Locker.mapping.keys.sort.should == ['one', 'two']
|
27
|
+
Watirloo::Locker.mapping['one'].should == Watirloo::Locker.mapping['two']
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'remove deletes a key value record ' do
|
31
|
+
Watirloo::Locker.remove 'two'
|
32
|
+
Watirloo::Locker.mapping.keys.should_not include('two')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'browser reattaches to named browser based on windows handle' do
|
36
|
+
ie = Watirloo::Locker.browser 'one'
|
37
|
+
ie.should be_kind_of(Watir::IE)
|
38
|
+
ie.hwnd.should == Watirloo::Locker.mapping['one']
|
39
|
+
ie.should exist
|
40
|
+
ie.close
|
41
|
+
ie.should_not exist
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'browser attach to nonexisting windows behaves like IE.attach, it raises error' do
|
45
|
+
sleep 6 # if previous test closes a browser we need to wait to ensure we don't reattach to a closing browser
|
46
|
+
(lambda {Watirloo::Locker.browser('one')}).should raise_error(Watir::Exception::NoMatchingWindowFoundException) #points to the same hwnd as 'one' but at this time does not exist any more
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/spec/page_spec.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Page class with face definitions" do
|
4
|
+
class Page1
|
5
|
+
include Watirloo::Page
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'has face method as singleton' do
|
9
|
+
Page1.singleton_methods.should include('face')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'face class method defines method' do
|
13
|
+
Page1.face(:bla) do
|
14
|
+
"hello"
|
15
|
+
end
|
16
|
+
page = Page1.new
|
17
|
+
page.should respond_to(:bla)
|
18
|
+
page.bla.should == 'hello'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'face accepts args used by method body' do
|
22
|
+
Page1.face(:foo) do |x|
|
23
|
+
x * 2
|
24
|
+
end
|
25
|
+
page = Page1.new
|
26
|
+
page.foo(2).should == 4
|
27
|
+
page.foo("bla").should == "blabla"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Page faces included in rspec" do
|
32
|
+
|
33
|
+
include Watirloo::Page
|
34
|
+
face(:last1) {doc.text_field(:name, 'last_name0')}
|
35
|
+
face(:last) {|nbr| doc.text_field(:name, "last_name#{nbr+1}")}
|
36
|
+
|
37
|
+
before do
|
38
|
+
browser.goto testfile('census.html')
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
it 'face defines a watir element access' do
|
43
|
+
last1.set "Zippididuda"
|
44
|
+
last1.value.should == 'Zippididuda'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'faces with arguments' do
|
48
|
+
last(1).set "Zorro"
|
49
|
+
last(1).value.should == "Zorro"
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Person Page interfaces defined by def wrappers and class definitions" do
|
4
|
+
|
5
|
+
include Watirloo::Page
|
6
|
+
# declare accessing elements
|
7
|
+
face( :first ) { doc.text_field(:name, 'first_nm') }
|
8
|
+
face( :street) { doc.text_field(:name, 'addr1') }
|
9
|
+
|
10
|
+
# def wrapper helper with suggested semantic name returns dom element
|
11
|
+
def last
|
12
|
+
doc.text_field(:name, 'last_nm')
|
13
|
+
end
|
14
|
+
|
15
|
+
def dob
|
16
|
+
doc.text_field(:name, 'dob')
|
17
|
+
end
|
18
|
+
|
19
|
+
before :each do
|
20
|
+
browser.goto testfile('person.html')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'calling face when there is wrapper method' do
|
24
|
+
last.set 'Wonkatonka'
|
25
|
+
last.value.should == 'Wonkatonka'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'calling interface when there is definition and no method' do
|
29
|
+
first.set 'Oompaloompa'
|
30
|
+
first.value.should == 'Oompaloompa'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'spray method by convetion has keys correspondig to interface names for watir elements' do
|
34
|
+
datamap = {:street => '13 Sad Enchiladas Lane', :dob => '02/03/1977'}
|
35
|
+
spray datamap
|
36
|
+
street.value.should == datamap[:street]
|
37
|
+
dob.value.should == datamap[:dob]
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe 'RadioGroup class access in watir browser' do
|
4
|
+
include Watirloo::Page
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto testfile('radio_group.html')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'browser responds to radio_group' do
|
11
|
+
browser.should respond_to(:radio_group)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'radio group needs :what value with implicit :how=name' do
|
15
|
+
rg = browser.radio_group('food')
|
16
|
+
rg.size.should == 3
|
17
|
+
rg.values.should == %w[hotdog burger tofu]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
describe 'RadioGroup class interface in watirloo' do
|
23
|
+
|
24
|
+
include Watirloo::Page
|
25
|
+
face :meals_to_go do
|
26
|
+
doc.radio_group('food')
|
27
|
+
end
|
28
|
+
|
29
|
+
before do
|
30
|
+
browser.goto testfile('radio_group.html')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'container radio_group method returns RadioGroup class' do
|
34
|
+
# verify browser namespace explicitly
|
35
|
+
if browser.kind_of?(FireWatir::Firefox)
|
36
|
+
meals_to_go.should be_kind_of(FireWatir::RadioGroup)
|
37
|
+
elsif browser.kind_of?(Watir::IE)
|
38
|
+
meals_to_go.should be_kind_of(Watir::RadioGroup)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'size or count returns how many radios in a group' do
|
43
|
+
meals_to_go.size.should == 3
|
44
|
+
meals_to_go.count.should == 3
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'values returns value attributes text items as an array' do
|
48
|
+
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
|
+
meals_to_go.selected.should == 'burger'
|
53
|
+
meals_to_go.selected_value.should == 'burger'
|
54
|
+
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
|
+
meals_to_go.set 3
|
59
|
+
meals_to_go.selected.should == 'tofu'
|
60
|
+
meals_to_go.selected_value.should == 'tofu'
|
61
|
+
meals_to_go.selected_values.should == ['tofu']
|
62
|
+
meals_to_go.selected.should_not == 'hotdog'
|
63
|
+
|
64
|
+
meals_to_go.set 1
|
65
|
+
meals_to_go.selected.should == 'hotdog'
|
66
|
+
meals_to_go.selected_value.should == 'hotdog'
|
67
|
+
meals_to_go.selected_values.should == ['hotdog']
|
68
|
+
meals_to_go.selected.should_not == 'tofu'
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'set selects radio by value in a group. selected returns value' do
|
72
|
+
meals_to_go.set 'hotdog'
|
73
|
+
meals_to_go.selected.should == 'hotdog'
|
74
|
+
meals_to_go.selected.should_not == 'tofu'
|
75
|
+
|
76
|
+
meals_to_go.set 'tofu'
|
77
|
+
meals_to_go.selected_value.should == 'tofu'
|
78
|
+
meals_to_go.selected.should_not == 'hotdog'
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'set position throws exception if number not within the range of group size' do
|
82
|
+
lambda{ meals_to_go.set 7 }.should raise_error(Watir::Exception::WatirException)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'set value throws exception if value not found in options' do
|
86
|
+
lambda{ meals_to_go.set 'banannnanna' }.should raise_error(Watir::Exception::WatirException)
|
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 sybmol is used. it should accept Fixnum or String element only' do
|
92
|
+
lambda{ meals_to_go.set :yes }.should raise_error(Watir::Exception::WatirException)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|