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,20 @@
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
+ <h3>Pets CheckboxGroup. Each has value. Acts like MultiSelectList. none, one ore more items can be checked.</h3>
12
+ <INPUT NAME="pets" TYPE="CHECKBOX" VALUE="cat">cat<br />
13
+ <INPUT NAME="pets" TYPE="CHECKBOX" VALUE="dog">dog<br />
14
+ <INPUT NAME="pets" TYPE="CHECKBOX" VALUE="zook">zook<br />
15
+ <INPUT NAME="pets" TYPE="CHECKBOX" VALUE="zebra">zebra<br />
16
+ <INPUT NAME="pets" TYPE="CHECKBOX" VALUE="wumpa">wumpa<br />
17
+ <h3>Single CheckboxToggle Only. Acts like RadioGroup on/off switch.</h3>
18
+ <INPUT NAME="singleIndicator" TYPE="checkbox">ToggleMe<br />
19
+ </body>
20
+ </html>
@@ -0,0 +1,32 @@
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></title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
10
+ </head>
11
+ <body>
12
+
13
+ <h3>Implicit label wraps text_field without for attribute. Click does not transfer focus to control</h3>
14
+ <form id="wrap_without_for"action="" method="get">
15
+ <p>
16
+ <label>First Name<INPUT type="text" name="fn"></label>
17
+ </p>
18
+ <p>
19
+ <label><INPUT type="text" name="ln">Last Name</label>
20
+ </p>
21
+ </form>
22
+
23
+ <h3>Explicit Label For Item with Id. Click transfers focus to control associated by id</h3>
24
+ <form id="label_for_id"action="" method="get">
25
+ <p>
26
+ <label for="first_nm">FirstName For</label><INPUT type="text" name="firstname" id="first_nm">
27
+ <INPUT type="text" name="lastname" id="last_nm"><label for="last_nm">LastName For</label>
28
+ </p>
29
+ </form>
30
+
31
+ </body>
32
+ </html>
@@ -0,0 +1,37 @@
1
+ <!--
2
+ Document : person
3
+ -->
4
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5
+ <html>
6
+ <head>
7
+ <title>Person</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9
+ </head>
10
+ <body>
11
+ <div id="personPanel">
12
+ <h2>Person Info</h2>
13
+ <p id="tagline">Some info about a person</p>
14
+ <form id="person" name="person" action="person.fake.page" method="post">
15
+ <br />Last Name: <input maxLength="45" size="25" name="last_nm" value="Begoodnuffski" />
16
+ <br />First Name: <input maxLength="20" size="10" name="first_nm" value="Joanney" />
17
+ <br />Gender: <select name="sex_cd">
18
+ <option value=" "></option>
19
+ <option value="M" selected>M</option>
20
+ <option value="F">F</option>
21
+ </select>
22
+ <br />Date Of Birth: <input maxLength="10" size="10" name="dob" value="05/09/1964" />
23
+ <br />Street Address<input maxLength="45" size="45" name="addr1" value="1600 Transylavnia Ave." />
24
+ <br />Has the following pets:
25
+ <SELECT name="pets" MULTIPLE SIZE=4>
26
+ <OPTION VALUE="o1">cat
27
+ <OPTION VALUE="o2">dog
28
+ <OPTION VALUE="o3">zook
29
+ <OPTION VALUE="o4">zebra
30
+ <OPTION VALUE="o5">wumpa
31
+
32
+ </SELECT>
33
+
34
+ </form>
35
+ </div>
36
+ </body>
37
+ </html>
@@ -0,0 +1,41 @@
1
+ <!--
2
+ Document : radio_group
3
+ -->
4
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5
+ <html>
6
+ <head>
7
+ <title>radio_groups</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9
+ </head>
10
+ <body>
11
+ <h3>wanna eat what?</h3>
12
+ <TABLE border="0">
13
+ <TBODY>
14
+ <TR>
15
+ <TD>
16
+ <INPUT type="radio" name="food" value="hotdog" />
17
+ </TD>
18
+ <TD>
19
+ Hothund
20
+ </TD>
21
+ </TR>
22
+ <TR>
23
+ <TD>
24
+ <INPUT type="radio" name="food" value="burger" checked />
25
+ </TD>
26
+ <TD>
27
+ Burgier
28
+ </TD>
29
+ </TR>
30
+ <TR>
31
+ <TD>
32
+ <INPUT type="radio" name="food" value="tofu" />
33
+ </TD>
34
+ <TD>
35
+ Tofoo
36
+ </TD>
37
+ </TR>
38
+ </TBODY>
39
+ </TABLE>
40
+ </body>
41
+ </html>
@@ -0,0 +1,82 @@
1
+ <!--
2
+ Document : select_lists
3
+ -->
4
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5
+ <html>
6
+ <head>
7
+ <title>select lists</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9
+ </head>
10
+ <body>
11
+ <form id="selectors" action="none.page" method="post">
12
+ <h3>multiple select</h3>
13
+ <select name="animals" multiple size=4>
14
+ <option value="o1">cat</option>
15
+ <option value="o2">dog</option>
16
+ <option value="o3">zook</option>
17
+ <option value="o4">zebra</option>
18
+ <option value="o5">wumpa</option>
19
+ </select>
20
+
21
+ <h3>single select</h3>
22
+ <select name="sex_cd">
23
+ <option value="" selected></option>
24
+ <option value="m">M</option>
25
+ <option value="f">F</option>
26
+ </select>
27
+
28
+ <h3>single select with no hidden values in options</h3>
29
+ <p>if value attribute is not set <a href="http://www.w3.org/TR/html401/interact/forms.html#edef-OPTGROUP">
30
+ the initial value is set to the contents of the option element.</a></p>
31
+ <select name="bubel">
32
+ <option selected></option>
33
+ <option>foobel</option>
34
+ <option>barbel</option>
35
+ <option>bazbel</option>
36
+ <option>chuchu</option>
37
+ </select>
38
+ </form>
39
+
40
+ <h3>select with 3 optgroups</h3>
41
+
42
+ <form id="optgroups" action="none.page" method="post">
43
+ <p></p>
44
+ <select name="cars" multiple size="10">
45
+ <option selected label="none" value="none">none</option>
46
+ <OPTGROUP label="economy">
47
+ <option label="yug" value="yugo">Yugo</option>
48
+ <option label="tra" value="trabi">Trabant</option>
49
+ </OPTGROUP>
50
+ <OPTGROUP label="midsize">
51
+ <option label="zig" value="ziguli">Ziguli Sport</option>
52
+ <option label="syr" value="syrenka">Syrenka 4 Door</option>
53
+ </OPTGROUP>
54
+ <OPTGROUP label="fullsize">
55
+ <option label="vol" value="volga">Czarna Volga</option>
56
+ <option label="lim" value="limo">Limozyna</option>
57
+ </OPTGROUP>
58
+ </select>
59
+
60
+ <p></p>
61
+ <select name="shoes">
62
+ <option selected label="none" value="none">none</option>
63
+ <OPTGROUP label="Beachware">
64
+ <option>YoFeet</option>
65
+ <option>Plestyk</option>
66
+ </OPTGROUP>
67
+ <OPTGROUP label="Runware">
68
+ <option>Adidasy</option>
69
+ <option>Najkee</option>
70
+ </OPTGROUP>
71
+ <OPTGROUP label="Cubicleware">
72
+ <option>Zocks</option>
73
+ <option>Bamboshki</option>
74
+ </OPTGROUP>
75
+ </select>
76
+
77
+
78
+ </form>
79
+
80
+
81
+ </body>
82
+ </html>
@@ -0,0 +1,64 @@
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.goto testfile('labels.html')
7
+ @page.add_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.add_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
+
@@ -0,0 +1,56 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ # def wrappers with suggested semantic names for elements
4
+ class Person < Watirloo::Page
5
+
6
+ def last
7
+ @b.text_field(:name, 'last_nm')
8
+ end
9
+
10
+ def first
11
+ @b.text_field(:name, 'first_nm')
12
+ end
13
+
14
+ def dob
15
+ @b.text_field(:name, 'dob')
16
+ end
17
+
18
+ def street
19
+ @b.text_field(:name, 'addr1')
20
+ end
21
+
22
+ def gender
23
+ @b.select_list(:name, 'sex_cd')
24
+ end
25
+
26
+ end
27
+
28
+
29
+ describe "Person Page with def wrapper methods" do
30
+
31
+ before :each do
32
+ @page = Person.new
33
+ @page.b.goto testfile('person.html')
34
+ end
35
+
36
+ it 'calling face when there is wrapper method' do
37
+
38
+ @page.last.set 'Wonkatonka'
39
+ @page.last.value.should == 'Wonkatonka'
40
+ @page.face(:last).value.should == 'Wonkatonka'
41
+
42
+ @page.face(:last).set 'Oompaloompa'
43
+ @page.last.value.should == 'Oompaloompa'
44
+
45
+ end
46
+
47
+ it 'spray using methods wrappers for watir elements' do
48
+ mapping = {:street => '13 Sad Enchiladas Lane', :dob => '02/03/1977'}
49
+ @page.spray mapping
50
+ @page.street.value.should == mapping[:street]
51
+ @page.dob.value.should == mapping[:dob]
52
+ end
53
+
54
+ end
55
+
56
+
@@ -0,0 +1,82 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class RadioGroupPage < Watirloo::Page
4
+ # RadioGroup Class refers to collection of radios sharing the same name
5
+ def meals_to_go
6
+ @b.radio_group('food')
7
+ end
8
+ end
9
+
10
+ describe 'RadioGroup class' do
11
+
12
+ before do
13
+ @page = RadioGroupPage.new
14
+ @page.b.goto testfile('radio_group.html')
15
+ end
16
+
17
+ it 'container radio_group method returns RadioGroup class' do
18
+ # verify browser namespace explicitly
19
+ if @page.b.kind_of?(FireWatir::Firefox)
20
+ @page.meals_to_go.kind_of?(FireWatir::RadioGroup).should.be true
21
+
22
+ elsif @page.b.kind_of?(Watir::IE)
23
+ @page.meals_to_go.kind_of?(Watir::RadioGroup).should.be true
24
+ end
25
+ end
26
+
27
+ it 'size or count returns how many radios in a group' do
28
+ @page.meals_to_go.size.should == 3
29
+ @page.meals_to_go.count.should == 3
30
+ end
31
+
32
+ it 'values returns value attributes text items as an array' do
33
+ @page.meals_to_go.values.should == ["hotdog", "burger", "tofu"]
34
+ end
35
+
36
+ it 'selected_value returns internal option value for selected radio item in a group' do
37
+ @page.meals_to_go.selected.should == 'burger'
38
+ @page.meals_to_go.selected_value.should == 'burger'
39
+ @page.meals_to_go.selected_values.should == ['burger'] # matches select_list api
40
+ end
41
+
42
+ it 'set selects radio by position in a group' do
43
+ @page.meals_to_go.set 3
44
+ @page.meals_to_go.selected.should == 'tofu'
45
+ @page.meals_to_go.selected_value.should == 'tofu'
46
+ @page.meals_to_go.selected_values.should == ['tofu']
47
+
48
+ @page.meals_to_go.set 1
49
+ @page.meals_to_go.selected.should == 'hotdog'
50
+ @page.meals_to_go.selected_value.should == 'hotdog'
51
+ @page.meals_to_go.selected_values.should == ['hotdog']
52
+ end
53
+
54
+ it 'set selects radio by value in a group' do
55
+ @page.meals_to_go.set 'hotdog'
56
+ @page.meals_to_go.selected.should == 'hotdog'
57
+
58
+ @page.meals_to_go.set 'tofu'
59
+ @page.meals_to_go.selected_value.should == 'tofu'
60
+ end
61
+
62
+ it 'set position throws exception if number not within the range of group size' do
63
+ assert_raise(Watir::Exception::WatirException) do
64
+ @page.meals_to_go.set 7
65
+ end
66
+ end
67
+
68
+ it 'set value throws exception if value not found in options' do
69
+ assert_raise(Watir::Exception::WatirException) do
70
+ @page.meals_to_go.set 'banannnanna'
71
+ end
72
+ end
73
+
74
+ # TODO do I want to provide mapping of human generated semantic values for radios
75
+ # to actual values here in the radio_group or at the Watirllo level only?
76
+ it 'set throws exception if other than Fixnum or String element is used' do
77
+ assert_raise(Watir::Exception::WatirException)do
78
+ @page.meals_to_go.set :yes
79
+ end
80
+ end
81
+
82
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ describe "select list as semantic face object on a page" 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
+ end
12
+
13
+ it 'face method with key parameter to construct SelectList per browser implementation' do
14
+ if @page.b.kind_of?(FireWatir::Firefox)
15
+ @page.face(:pets).kind_of?(FireWatir::SelectList).should == true
16
+ @page.face(:gender).kind_of?(FireWatir::SelectList).should == true
17
+
18
+ elsif @page.b.kind_of? Watir::IE
19
+ @page.face(:pets).kind_of?(Watir::SelectList).should == true
20
+ @page.face(:gender).kind_of?(Watir::SelectList).should == true
21
+ end
22
+ end
23
+
24
+ it 'face(:facename) and browser.select_list access the same control' do
25
+ @page.b.select_list(:name, 'sex_cd').values.should == @page.gender.values
26
+ @page.b.select_list(:name, 'animals').values.should == @page.pets.values
27
+ end
28
+
29
+
30
+ it 'face(:facename) and facename access the same control' do
31
+ @page.face(:gender).items.should == @page.gender.items
32
+ @page.face(:pets).items.should == @page.pets.items
33
+ end
34
+
35
+ it 'facename method matching modeling semantic object accessor' do
36
+ if @page.b.kind_of?(FireWatir::Firefox)
37
+ @page.pets.kind_of?(FireWatir::SelectList).should == true
38
+ @page.gender.kind_of?(FireWatir::SelectList).should == true
39
+
40
+ elsif @page.b.kind_of?(Watir::IE)
41
+ @page.pets.kind_of?(Watir::SelectList).should == true
42
+ @page.gender.kind_of?(Watir::SelectList).should == true
43
+ end
44
+
45
+ end
46
+ end