firewatir 1.2.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/firewatir.rb +50 -0
- data/lib/firewatir/MozillaBaseElement.rb +1863 -0
- data/lib/firewatir/container.rb +534 -0
- data/lib/firewatir/exceptions.rb +10 -0
- data/lib/firewatir/firefox.rb +1127 -0
- data/lib/firewatir/htmlelements.rb +1911 -0
- data/lib/firewatir/version.rb +5 -0
- data/{firewatir → lib/firewatir}/winClicker.rb +0 -0
- data/{firewatir → lib/firewatir}/x11.rb +0 -0
- data/unittests/attach_to_new_window_test.rb +20 -12
- data/unittests/bug_fixes_test.rb +79 -69
- data/unittests/buttons_xpath_test.rb +45 -44
- data/unittests/checkbox_test.rb +86 -85
- data/unittests/checkbox_xpath_test.rb +58 -58
- data/unittests/div_test.rb +117 -115
- data/unittests/filefield_test.rb +12 -12
- data/unittests/filefield_xpath_test.rb +11 -11
- data/unittests/form_test.rb +134 -133
- data/unittests/frame_test.rb +42 -41
- data/unittests/hidden_test.rb +40 -40
- data/unittests/hidden_xpath_test.rb +32 -32
- data/unittests/images_test.rb +85 -84
- data/unittests/images_xpath_test.rb +57 -56
- data/unittests/iostring_test.rb +1 -1
- data/unittests/javascript_test.rb +42 -38
- data/unittests/links_test.rb +88 -86
- data/unittests/links_xpath_test.rb +38 -38
- data/unittests/mozilla_all_tests.rb +2 -14
- data/unittests/pre_test.rb +27 -25
- data/unittests/radios_test.rb +86 -86
- data/unittests/radios_xpath_test.rb +48 -48
- data/unittests/redirect_test.rb +20 -19
- data/unittests/selectbox_test.rb +72 -71
- data/unittests/selectbox_xpath_test.rb +58 -56
- data/unittests/setup.rb +22 -27
- data/unittests/table_test.rb +89 -88
- data/unittests/table_xpath_test.rb +37 -36
- data/unittests/textfields_test.rb +105 -102
- data/unittests/textfields_xpath_test.rb +53 -52
- metadata +37 -18
- data/MozillaBaseElement.rb +0 -1780
- data/container.rb +0 -900
- data/firewatir.rb +0 -1195
- data/firewatir/exceptions.rb +0 -44
- data/firewatir/testUnitAddons.rb +0 -8
- data/htmlelements.rb +0 -2281
- data/unittests/buttons_test.rb +0 -215
@@ -1,100 +1,100 @@
|
|
1
1
|
# feature tests for Radio Buttons
|
2
2
|
# revision: $Revision: 1.0 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Radios_XPath < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup()
|
11
|
-
|
11
|
+
goto_page("radioButtons1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_Radio_Exists
|
15
|
-
assert(
|
16
|
-
assert(
|
15
|
+
assert(browser.radio(:xpath, "//input[@name='box1']").exists?)
|
16
|
+
assert(browser.radio(:xpath, "//input[@id='box5']").exists?)
|
17
17
|
|
18
|
-
assert_false(
|
19
|
-
assert_false(
|
18
|
+
assert_false(browser.radio(:xpath, "//input[@name='missingname']").exists?)
|
19
|
+
assert_false(browser.radio(:xpath, "//input[@id='missingid']").exists?)
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_Radio_Enabled
|
23
|
-
assert_raises(UnknownObjectException
|
24
|
-
assert_raises(UnknownObjectException
|
25
|
-
assert_raises(UnknownObjectException
|
23
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").enabled? }
|
24
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@id='noName']").enabled? }
|
25
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='box4' and @value='6']").enabled? }
|
26
26
|
|
27
|
-
assert_false(
|
28
|
-
assert(
|
29
|
-
assert(
|
27
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']").enabled?)
|
28
|
+
assert(browser.radio(:xpath, "//input[@id='box5']").enabled?)
|
29
|
+
assert(browser.radio(:xpath, "//input[@name='box1']").enabled?)
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_little
|
33
|
-
assert_false(
|
33
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_onClick
|
37
|
-
assert_false(
|
38
|
-
|
39
|
-
assert(
|
37
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
38
|
+
browser.radio(:xpath, "//input[@name='box5' and @value='1']").set
|
39
|
+
assert(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
40
40
|
|
41
|
-
|
42
|
-
assert_false(
|
41
|
+
browser.radio(:xpath, "//input[@name='box5' and @value='2']").set
|
42
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_Radio_isSet
|
46
|
-
assert_raises(UnknownObjectException
|
46
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").isSet? }
|
47
47
|
|
48
|
-
puts "radio 1 is set : #{
|
49
|
-
assert_false(
|
48
|
+
puts "radio 1 is set : #{ browser.radio(:xpath, "//input[@name='box1']").isSet? } "
|
49
|
+
assert_false(browser.radio(:xpath, "//input[@name='box1']").isSet?)
|
50
50
|
|
51
|
-
assert(
|
52
|
-
assert_false(
|
51
|
+
assert(browser.radio(:xpath, "//input[@name='box3']").isSet?)
|
52
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']").isSet?)
|
53
53
|
|
54
|
-
assert(
|
55
|
-
assert_false(
|
54
|
+
assert( browser.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
|
55
|
+
assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='2']").isSet?)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_radio_clear
|
59
|
-
assert_raises(UnknownObjectException
|
59
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").clear }
|
60
60
|
|
61
|
-
|
62
|
-
assert_false(
|
61
|
+
browser.radio(:xpath, "//input[@name='box1']").clear
|
62
|
+
assert_false(browser.radio(:xpath, "//input[@name='box1']").isSet?)
|
63
63
|
|
64
|
-
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) {
|
65
|
-
assert_false(
|
64
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']").clear }
|
65
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']").isSet?)
|
66
66
|
|
67
|
-
|
68
|
-
assert_false(
|
67
|
+
browser.radio(:xpath, "//input[@name='box3']").clear
|
68
|
+
assert_false(browser.radio(:xpath, "//input[@name='box3']").isSet?)
|
69
69
|
|
70
|
-
|
71
|
-
assert_false(
|
70
|
+
browser.radio(:xpath, "//input[@name='box4' and @value='1']").clear
|
71
|
+
assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_radio_getState
|
75
|
-
assert_raises(UnknownObjectException
|
75
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").getState }
|
76
76
|
|
77
|
-
assert_equal( false ,
|
78
|
-
assert_equal( true ,
|
77
|
+
assert_equal( false , browser.radio(:xpath, "//input[@name='box1']").getState )
|
78
|
+
assert_equal( true , browser.radio(:xpath, "//input[@name='box3']").getState)
|
79
79
|
|
80
80
|
# radioes that have the same name but different values
|
81
|
-
assert_equal( false ,
|
82
|
-
assert_equal( true ,
|
81
|
+
assert_equal( false , browser.radio(:xpath, "//input[@name='box4' and @value='2']").getState )
|
82
|
+
assert_equal( true , browser.radio(:xpath, "//input[@name='box4' and @value='1']").getState)
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_radio_set
|
86
|
-
assert_raises(UnknownObjectException
|
87
|
-
|
88
|
-
assert(
|
86
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").set }
|
87
|
+
browser.radio(:xpath, "//input[@name='box1']").set
|
88
|
+
assert(browser.radio(:xpath, "//input[@name='box1']").isSet?)
|
89
89
|
|
90
|
-
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) {
|
90
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']").set }
|
91
91
|
|
92
|
-
|
93
|
-
assert(
|
92
|
+
browser.radio(:xpath, "//input[@name='box3']").set
|
93
|
+
assert(browser.radio(:xpath, "//input[@name='box3']").isSet?)
|
94
94
|
|
95
95
|
# radioes that have the same name but different values
|
96
|
-
|
97
|
-
assert(
|
96
|
+
browser.radio(:xpath, "//input[@name='box4' and @value='3']").set
|
97
|
+
assert(browser.radio(:xpath, "//input[@name='box4' and @value='3']").isSet?)
|
98
98
|
end
|
99
99
|
|
100
100
|
end
|
data/unittests/redirect_test.rb
CHANGED
@@ -1,40 +1,41 @@
|
|
1
1
|
# feature tests for Javascript redirect
|
2
2
|
# revision: $Revision: 1.0 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Redirect < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
8
|
+
|
10
9
|
def setup
|
11
|
-
|
10
|
+
goto_page("redirect.html")
|
12
11
|
end
|
13
12
|
|
14
13
|
def goto_multiple_redirect
|
15
|
-
|
14
|
+
goto_page("redirect1.html")
|
16
15
|
end
|
17
16
|
|
17
|
+
tag_method :test_single_redirect, :fails_on_ie
|
18
18
|
def test_single_redirect
|
19
|
-
assert_raises(UnknownObjectException) {
|
20
|
-
assert_raises(UnknownObjectException) {
|
19
|
+
assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
|
20
|
+
assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
|
21
21
|
|
22
|
-
assert(
|
23
|
-
|
24
|
-
assert(
|
25
|
-
|
26
|
-
assert(
|
22
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
23
|
+
browser.div(:id , "div3").click
|
24
|
+
assert(browser.text_field(:name, "text1").verify_contains("1") )
|
25
|
+
browser.div(:id , "div4").click
|
26
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
27
27
|
end
|
28
28
|
|
29
|
+
tag_method :test_multiple_redirect, :fails_on_ie
|
29
30
|
def test_multiple_redirect
|
30
31
|
goto_multiple_redirect()
|
31
|
-
assert_raises(UnknownObjectException) {
|
32
|
-
assert_raises(UnknownObjectException) {
|
32
|
+
assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
|
33
|
+
assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
|
33
34
|
|
34
|
-
assert(
|
35
|
-
|
36
|
-
assert(
|
37
|
-
|
38
|
-
assert(
|
35
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
36
|
+
browser.div(:id , "div3").click
|
37
|
+
assert(browser.text_field(:name, "text1").verify_contains("1") )
|
38
|
+
browser.div(:id , "div4").click
|
39
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
39
40
|
end
|
40
41
|
end
|
data/unittests/selectbox_test.rb
CHANGED
@@ -1,141 +1,142 @@
|
|
1
1
|
# feature tests for Select Boxes
|
2
2
|
# revision: $Revision: 1.0 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_SelectList < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup()
|
11
|
-
|
11
|
+
goto_page("selectboxes1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_textBox_Exists
|
15
|
-
assert(
|
16
|
-
assert_false(
|
17
|
-
assert_false(
|
15
|
+
assert(browser.select_list(:name, "sel1").exists?)
|
16
|
+
assert_false(browser.select_list(:name, "missing").exists?)
|
17
|
+
assert_false(browser.select_list(:id, "missing").exists?)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_select_list_enabled
|
21
|
-
assert(
|
22
|
-
assert_raises(UnknownObjectException) {
|
21
|
+
assert(browser.select_list(:name, "sel1").enabled?)
|
22
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").enabled? }
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_select_list_getAllContents
|
26
|
-
assert_raises(UnknownObjectException) {
|
26
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getAllContents }
|
27
27
|
assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
|
28
|
-
|
28
|
+
browser.select_list(:name, "sel1").getAllContents)
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_Option_text_select
|
32
|
-
assert_raises(UnknownObjectException) {
|
33
|
-
assert_raises(UnknownObjectException) {
|
34
|
-
assert_raises(MissingWayOfFindingObjectException) {
|
32
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").select }
|
33
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, /missing/).select }
|
34
|
+
assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
|
35
35
|
|
36
36
|
# the select method keeps any currently selected items - use the clear selection method first
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal( ["Option 1" ] ,
|
37
|
+
browser.select_list( :name , "sel1").clearSelection
|
38
|
+
browser.select_list( :name , "sel1").option(:text, "Option 1").select
|
39
|
+
assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
|
40
40
|
end
|
41
41
|
|
42
42
|
|
43
|
+
tag_method :test_option_class_name, :fails_on_ie
|
43
44
|
def test_option_class_name
|
44
45
|
|
45
46
|
# the option object doesnt inherit from element, so this doesnt work
|
46
|
-
assert_raises(UnknownObjectException) {
|
47
|
-
assert_equal("option_style" ,
|
48
|
-
assert_equal("" ,
|
47
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").class_name }
|
48
|
+
assert_equal("option_style" , browser.select_list(:name, "sel2").option(:value , 'o2').class_name)
|
49
|
+
assert_equal("" , browser.select_list(:name, "sel2").option(:value , 'o1').class_name)
|
49
50
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def test_selectBox_select_using_value
|
53
|
-
assert_raises(UnknownObjectException) {
|
54
|
-
assert_raises(NoValueFoundException) {
|
55
|
-
assert_raises(NoValueFoundException) {
|
54
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getSelectedItems }
|
55
|
+
assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value("missing item") }
|
56
|
+
assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value(/missing/) }
|
56
57
|
|
57
58
|
# the select method keeps any currently selected items - use the clear selectcion method first
|
58
|
-
|
59
|
-
|
60
|
-
assert_equal( ["Option 1" ] ,
|
59
|
+
browser.select_list( :name , "sel1").clearSelection
|
60
|
+
browser.select_list( :name , "sel1").select_value("o1")
|
61
|
+
assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
assert_equal( ["Option 2" ] ,
|
63
|
+
browser.select_list( :name , "sel1").clearSelection
|
64
|
+
browser.select_list( :name , "sel1").select_value(/2/)
|
65
|
+
assert_equal( ["Option 2" ] , browser.select_list(:name, "sel1").getSelectedItems)
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
browser.select_list( :name , "sel2").clearSelection
|
68
|
+
browser.select_list( :name , "sel2").select_value(/4/)
|
69
|
+
browser.select_list( :name , "sel2").select_value(/2/)
|
69
70
|
assert_equal( ["Option 2" , "Option 4" ] ,
|
70
|
-
|
71
|
+
browser.select_list(:name, "sel2").getSelectedItems)
|
71
72
|
|
72
73
|
# these are to test the onchange event
|
73
74
|
# the event shouldnt get fired, as this is the selected item
|
74
|
-
|
75
|
-
assert_false(
|
75
|
+
browser.select_list( :name , "sel3").select_value( /3/ )
|
76
|
+
assert_false(browser.text.include?("Pass") )
|
76
77
|
end
|
77
78
|
|
78
79
|
def test_select_list_select_using_value2
|
79
80
|
# the event should get fired
|
80
|
-
|
81
|
-
assert(
|
81
|
+
browser.select_list( :name , "sel3").select_value( /2/ )
|
82
|
+
assert(browser.text.include?("PASS") )
|
82
83
|
end
|
83
84
|
|
84
85
|
def test_select_list_properties
|
85
|
-
assert_raises(UnknownObjectException) {
|
86
|
-
assert_raises(UnknownObjectException) {
|
87
|
-
assert_raises(UnknownObjectException) {
|
88
|
-
assert_raises(UnknownObjectException) {
|
89
|
-
assert_raises(UnknownObjectException) {
|
86
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
|
87
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
|
88
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
|
89
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled }
|
90
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
|
90
91
|
|
91
|
-
assert_equal("o3" ,
|
92
|
-
assert_equal("sel1" ,
|
93
|
-
assert_equal("" ,
|
94
|
-
assert_equal("select-one",
|
95
|
-
assert_equal("select-multiple",
|
92
|
+
assert_equal("o3" , browser.select_list(:index, 1).value)
|
93
|
+
assert_equal("sel1" , browser.select_list(:index, 1).name )
|
94
|
+
assert_equal("" , browser.select_list(:index, 1).id )
|
95
|
+
assert_equal("select-one", browser.select_list(:index, 1).type )
|
96
|
+
assert_equal("select-multiple", browser.select_list(:index, 2).type )
|
96
97
|
|
97
|
-
|
98
|
-
assert_equal("o1" ,
|
98
|
+
browser.select_list(:index,1).select(/1/)
|
99
|
+
assert_equal("o1" , browser.select_list(:index, 1).value)
|
99
100
|
|
100
|
-
assert_false(
|
101
|
-
assert(
|
102
|
-
assert(
|
101
|
+
assert_false( browser.select_list(:index, 1).disabled )
|
102
|
+
assert( browser.select_list(:index, 4).disabled )
|
103
|
+
assert( browser.select_list(:id, 'selectbox_4').disabled )
|
103
104
|
end
|
104
105
|
|
105
106
|
def test_select_list_iterator
|
106
|
-
assert_equal(5,
|
107
|
-
assert_equal("o3" ,
|
108
|
-
assert_equal("sel1" ,
|
109
|
-
assert_equal("select-one",
|
110
|
-
assert_equal("select-multiple" ,
|
107
|
+
assert_equal(5, browser.select_lists.length)
|
108
|
+
assert_equal("o3" , browser.select_lists[1].value)
|
109
|
+
assert_equal("sel1" , browser.select_lists[1].name )
|
110
|
+
assert_equal("select-one", browser.select_lists[1].type )
|
111
|
+
assert_equal("select-multiple" , browser.select_lists[2].type )
|
111
112
|
|
112
113
|
index=1
|
113
|
-
|
114
|
-
assert_equal(
|
115
|
-
assert_equal(
|
116
|
-
assert_equal(
|
117
|
-
assert_equal(
|
114
|
+
browser.select_lists.each do |l|
|
115
|
+
assert_equal( browser.select_list(:index, index).name , l.name )
|
116
|
+
assert_equal( browser.select_list(:index, index).id , l.id )
|
117
|
+
assert_equal( browser.select_list(:index, index).type , l.type )
|
118
|
+
assert_equal( browser.select_list(:index, index).value , l.value )
|
118
119
|
index+=1
|
119
120
|
end
|
120
|
-
assert_equal( index-1,
|
121
|
+
assert_equal( index-1, browser.select_lists.length)
|
121
122
|
# Bug Fix 25
|
122
|
-
|
123
|
+
browser.select_lists.each { |list| puts list.getAllContents() }
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
126
127
|
class TC_Select_Options < Test::Unit::TestCase
|
127
|
-
|
128
|
-
|
128
|
+
tags :fails_on_ie
|
129
|
+
|
129
130
|
def setup()
|
130
|
-
|
131
|
+
goto_page("select_tealeaf.html")
|
131
132
|
end
|
132
133
|
|
133
134
|
def test_options_text
|
134
|
-
|
135
|
-
assert(
|
136
|
-
assert_equal( [">=" ] ,
|
137
|
-
assert_equal( "=" ,
|
138
|
-
assert_equal( "0" ,
|
135
|
+
browser.select_list(:name, 'op_numhits').option(:text, '>=').select
|
136
|
+
assert(browser.select_list(:name, 'op_numhits').option(:text, '>=').selected)
|
137
|
+
assert_equal( [">=" ] , browser.select_list(:name, "op_numhits").getSelectedItems)
|
138
|
+
assert_equal( "=" , browser.select_list(:name, "op_numhits")[1].text)
|
139
|
+
assert_equal( "0" , browser.select_list(:name, "op_numhits")[1].value)
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
@@ -1,127 +1,129 @@
|
|
1
1
|
# feature tests for Select Boxes
|
2
2
|
# revision: $Revision: 1.0 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Selectbox_XPath < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup()
|
11
|
-
|
11
|
+
goto_page("selectboxes1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_textBox_Exists
|
15
|
-
assert(
|
16
|
-
assert_false(
|
17
|
-
assert_false(
|
15
|
+
assert(browser.select_list(:xpath, "//select[@name='sel1']").exists?)
|
16
|
+
assert_false(browser.select_list(:xpath, "//select[@name='missing']").exists?)
|
17
|
+
assert_false(browser.select_list(:xpath, "//select[@id='missing']").exists?)
|
18
18
|
end
|
19
19
|
|
20
|
+
tag_method :test_element_by_xpath_class, :fails_on_ie
|
20
21
|
def test_element_by_xpath_class
|
21
|
-
element =
|
22
|
-
|
22
|
+
element = browser.element_by_xpath("//select[@name='sel1']")
|
23
|
+
assert_class(element, 'SelectList')
|
23
24
|
# FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
|
24
25
|
# TODO: If element is not present, this should return null
|
25
|
-
#element =
|
26
|
+
#element = browser.element_by_xpath("//select[@name='missing']")
|
26
27
|
#assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
|
27
28
|
# FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
|
28
29
|
# TODO: If element is not present, this should return null
|
29
|
-
#element =
|
30
|
+
#element = browser.element_by_xpath("//select[@id='missing']")
|
30
31
|
#assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
|
31
32
|
end
|
32
33
|
|
33
34
|
def test_select_list_enabled
|
34
|
-
assert(
|
35
|
-
assert_raises(UnknownObjectException) {
|
35
|
+
assert(browser.select_list(:xpath, "//select[@name='sel1']").enabled?)
|
36
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").enabled? }
|
36
37
|
end
|
37
38
|
|
38
39
|
def test_select_list_getAllContents
|
39
|
-
assert_raises(UnknownObjectException) {
|
40
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getAllContents }
|
40
41
|
assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
|
41
|
-
|
42
|
+
browser.select_list(:xpath, "//select[@name='sel1']").getAllContents)
|
42
43
|
end
|
43
44
|
|
44
45
|
def test_select_list_getSelectedItems
|
45
|
-
assert_raises(UnknownObjectException) {
|
46
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
|
46
47
|
assert_equal( ["Option 3" ] ,
|
47
|
-
|
48
|
+
browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
|
48
49
|
assert_equal( ["Option 3" , "Option 6" ] ,
|
49
|
-
|
50
|
+
browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
|
50
51
|
end
|
51
52
|
|
53
|
+
tag_method :test_clearSelection, :fails_on_ie
|
52
54
|
def test_clearSelection
|
53
|
-
assert_raises(UnknownObjectException) {
|
54
|
-
|
55
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").clearSelection }
|
56
|
+
browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
|
55
57
|
|
56
58
|
# the box sel1 has no ability to have a de-selected item
|
57
59
|
# By default Option 1 will be selected
|
58
|
-
assert_equal( ["Option 1" ] ,
|
60
|
+
assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
|
59
61
|
|
60
|
-
|
61
|
-
assert_equal( [ ] ,
|
62
|
+
browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
|
63
|
+
assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
|
62
64
|
end
|
63
65
|
|
64
66
|
def test_select_list_select
|
65
|
-
assert_raises(UnknownObjectException) {
|
66
|
-
assert_raises(NoValueFoundException) {
|
67
|
-
assert_raises(NoValueFoundException) {
|
67
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
|
68
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select("missing item") }
|
69
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select(/missing/) }
|
68
70
|
|
69
71
|
# the select method keeps any currently selected items - use the clear selectcion method first
|
70
|
-
|
71
|
-
|
72
|
-
assert_equal( ["Option 1" ] ,
|
72
|
+
browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
|
73
|
+
browser.select_list(:xpath, "//select[@name='sel1']").select("Option 1")
|
74
|
+
assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
-
assert_equal( ["Option 2" ] ,
|
76
|
+
browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
|
77
|
+
browser.select_list(:xpath, "//select[@name='sel1']").select(/2/)
|
78
|
+
assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
|
81
|
+
browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
|
82
|
+
browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
|
81
83
|
assert_equal( ["Option 2" , "Option 4" ] ,
|
82
|
-
|
84
|
+
browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
|
83
85
|
|
84
86
|
# these are to test the onchange event
|
85
87
|
# the event shouldnt get fired, as this is the selected item
|
86
|
-
|
87
|
-
assert_false(
|
88
|
+
browser.select_list(:xpath, "//select[@name='sel3']").select( /3/ )
|
89
|
+
assert_false(browser.text.include?("Pass") )
|
88
90
|
end
|
89
91
|
|
90
92
|
def test_select_list_select2
|
91
93
|
# the event should get fired
|
92
|
-
|
93
|
-
assert(
|
94
|
+
browser.select_list(:xpath, "//select[@name='sel3']").select( /2/ )
|
95
|
+
assert(browser.text.include?("PASS") )
|
94
96
|
end
|
95
97
|
|
96
98
|
def test_select_list_select_using_value
|
97
|
-
assert_raises(UnknownObjectException) {
|
98
|
-
assert_raises(NoValueFoundException) {
|
99
|
-
assert_raises(NoValueFoundException) {
|
99
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
|
100
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value("missing item") }
|
101
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value(/missing/) }
|
100
102
|
|
101
103
|
# the select method keeps any currently selected items - use the clear selectcion method first
|
102
|
-
|
103
|
-
|
104
|
-
assert_equal( ["Option 1" ] ,
|
104
|
+
browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
|
105
|
+
browser.select_list(:xpath, "//select[@name='sel1']").select_value("o1")
|
106
|
+
assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
assert_equal( ["Option 2" ] ,
|
108
|
+
browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
|
109
|
+
browser.select_list(:xpath, "//select[@name='sel1']").select_value(/2/)
|
110
|
+
assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
|
109
111
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
assert_equal( ["Option 2" , "Option 4" ] ,
|
112
|
+
browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
|
113
|
+
browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
|
114
|
+
browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
|
115
|
+
assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
|
114
116
|
|
115
117
|
# these are to test the onchange event
|
116
118
|
# the event shouldnt get fired, as this is the selected item
|
117
|
-
|
118
|
-
assert_false(
|
119
|
+
browser.select_list(:xpath, "//select[@name='sel3']").select_value( /3/ )
|
120
|
+
assert_false(browser.text.include?("Pass") )
|
119
121
|
end
|
120
122
|
|
121
123
|
def test_select_list_select_using_value2
|
122
124
|
# the event should get fired
|
123
|
-
|
124
|
-
assert(
|
125
|
+
browser.select_list(:xpath, "//select[@name='sel3']").select_value( /2/ )
|
126
|
+
assert(browser.text.include?("PASS") )
|
125
127
|
end
|
126
128
|
|
127
129
|
end
|