sahi 1.0.0 → 1.0.1
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/lib/sahi.rb +50 -23
- data/test/sahi_test.rb +340 -313
- metadata +7 -4
data/lib/sahi.rb
CHANGED
@@ -4,24 +4,25 @@ require 'guid'
|
|
4
4
|
require 'Platform'
|
5
5
|
|
6
6
|
module Sahi
|
7
|
-
# The Browser class controls different
|
7
|
+
# The Browser class controls different browsers via Sahi's proxy.
|
8
|
+
#
|
8
9
|
# Thank you Sai Venkat for helping kickstart the ruby driver.
|
9
10
|
#
|
10
11
|
# Author:: Narayan Raman (mailto:narayan@sahi.co.in)
|
11
12
|
# Copyright:: Copyright (c) 2006 V Narayan Raman
|
12
13
|
# License:: Apache License, Version 2.0
|
13
14
|
#
|
14
|
-
# Download Sahi from http://sahi.co.in/
|
15
|
+
# Download Sahi from http://sahi.co.in/ .
|
15
16
|
# Java 1.5 or greater is needed to run Sahi.
|
16
17
|
#
|
17
18
|
# Start Sahi:
|
18
|
-
# cd sahi\userdata\bin
|
19
|
-
# start_sahi.bat
|
19
|
+
# cd sahi\userdata\bin;
|
20
|
+
# start_sahi.bat;
|
20
21
|
#
|
21
22
|
# or
|
22
23
|
#
|
23
|
-
# cd sahi/userdata/bin
|
24
|
-
# start_sahi.sh
|
24
|
+
# cd sahi/userdata/bin;
|
25
|
+
# start_sahi.sh;
|
25
26
|
#
|
26
27
|
# Point the browser proxy settings to localhost 9999.
|
27
28
|
#
|
@@ -113,20 +114,16 @@ module Sahi
|
|
113
114
|
def response(url, qs={})
|
114
115
|
return Net::HTTP.post_form(URI.parse(url), qs).body
|
115
116
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
def navigate_to(url, forceReload=false)
|
122
|
-
execute_step("_sahi._navigateTo(\"" + url + "\", "+ (forceReload.to_s()) +")");
|
117
|
+
|
118
|
+
# navigates to the given url
|
119
|
+
def navigate_to(url, force_reload=false)
|
120
|
+
execute_step("_sahi._navigateTo(\"" + url + "\", "+ (force_reload.to_s()) +")");
|
123
121
|
end
|
124
122
|
|
125
123
|
def execute_step(step)
|
126
124
|
if popup?()
|
127
125
|
step = "_sahi._popup(#{Utils.quoted(@popup_name)})." + step
|
128
126
|
end
|
129
|
-
puts step if @print_steps
|
130
127
|
exec_command("setStep", {"step" => step})
|
131
128
|
i = 0
|
132
129
|
while (i < 500)
|
@@ -258,7 +255,7 @@ module Sahi
|
|
258
255
|
return fetch("_sahi._title()")
|
259
256
|
end
|
260
257
|
|
261
|
-
# waits for specified time (in seconds)
|
258
|
+
# waits for specified time (in seconds).
|
262
259
|
# if a block is passed, it will wait till the block evaluates to true or till the specified timeout, which ever is earlier.
|
263
260
|
def wait(timeout)
|
264
261
|
total = 0;
|
@@ -279,7 +276,9 @@ module Sahi
|
|
279
276
|
end
|
280
277
|
end
|
281
278
|
end
|
282
|
-
|
279
|
+
|
280
|
+
#private :check_proxy, :is_ready?, :exec_command, :check_nil
|
281
|
+
|
283
282
|
end
|
284
283
|
|
285
284
|
|
@@ -299,7 +298,8 @@ module Sahi
|
|
299
298
|
class ElementStub
|
300
299
|
@@actions = {"click"=>"click", "mouse_over"=>"mouseOver",
|
301
300
|
"focus"=>"focus", "remove_focus"=>"removeFocus",
|
302
|
-
"check"=>"check", "uncheck"=>"uncheck"
|
301
|
+
"check"=>"check", "uncheck"=>"uncheck",
|
302
|
+
"dblclick"=>"doubleClick", "right_click"=>"rightClick"}
|
303
303
|
def initialize (browser, type, identifiers)
|
304
304
|
@type = type
|
305
305
|
@browser = browser
|
@@ -319,7 +319,7 @@ module Sahi
|
|
319
319
|
end
|
320
320
|
|
321
321
|
# drag element and drop on another element
|
322
|
-
def
|
322
|
+
def drag_and_drop_on(el2)
|
323
323
|
@browser.execute_step("_sahi._dragDrop(#{self.to_s()}, #{el2.to_s()})")
|
324
324
|
end
|
325
325
|
|
@@ -354,7 +354,7 @@ module Sahi
|
|
354
354
|
end
|
355
355
|
|
356
356
|
# returns checked state of checkbox or radio button
|
357
|
-
def checked()
|
357
|
+
def checked?()
|
358
358
|
return fetch("checked") == "true";
|
359
359
|
end
|
360
360
|
|
@@ -395,15 +395,41 @@ module Sahi
|
|
395
395
|
end
|
396
396
|
|
397
397
|
# returns true if the element exists on the browser
|
398
|
-
def exists?
|
399
|
-
|
398
|
+
def exists?(optimistic = false)
|
399
|
+
return self.exists1?() if optimistic;
|
400
|
+
(1..5).each do
|
401
|
+
return true if self.exists1?();
|
402
|
+
end
|
403
|
+
return false;
|
400
404
|
end
|
401
405
|
|
406
|
+
def exists1?
|
407
|
+
return "true".eql?(@browser.fetch("_sahi._exists(#{self.to_s()})"))
|
408
|
+
end
|
409
|
+
|
402
410
|
# returns true if the element exists and is visible on the browser
|
403
|
-
def visible?
|
404
|
-
|
411
|
+
def visible?(optimistic = false)
|
412
|
+
return self.visible1?() if optimistic;
|
413
|
+
(1..5).each do
|
414
|
+
return true if self.visible1?();
|
415
|
+
end
|
416
|
+
return false;
|
405
417
|
end
|
406
418
|
|
419
|
+
def visible1?
|
420
|
+
return "true".eql?(@browser.fetch("_sahi._isVisible(#{self.to_s()})"))
|
421
|
+
end
|
422
|
+
|
423
|
+
# returns true if the element contains this text
|
424
|
+
def contains_text?(text)
|
425
|
+
return @browser.fetch("_sahi._containsText(#{self.to_s()}, #{Utils.quoted(text)})")
|
426
|
+
end
|
427
|
+
|
428
|
+
# returns true if the element contains this html
|
429
|
+
def contains_html?(html)
|
430
|
+
return @browser.fetch("_sahi._containsHTML(#{self.to_s()}, #{Utils.quoted(html)})")
|
431
|
+
end
|
432
|
+
|
407
433
|
def to_s
|
408
434
|
return "_sahi._#{@type }(#{concat_identifiers(@identifiers).join(", ") })"
|
409
435
|
end
|
@@ -411,6 +437,7 @@ module Sahi
|
|
411
437
|
def concat_identifiers(ids)
|
412
438
|
return ids.collect {|id| id.kind_of?(String) ? Utils.quoted(id) : id.to_s()}
|
413
439
|
end
|
440
|
+
#private :concat_identifiers, :exists1?, :visible1?
|
414
441
|
end
|
415
442
|
|
416
443
|
class Utils
|
data/test/sahi_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require
|
2
|
+
require 'sahi'
|
3
3
|
|
4
4
|
class SahiDriverTest < Test::Unit::TestCase
|
5
5
|
def setup
|
@@ -17,15 +17,18 @@ class SahiDriverTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def init_browser()
|
20
|
-
userdata_dir = "
|
20
|
+
userdata_dir = "../../userdata"
|
21
21
|
browser_path = "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
|
22
22
|
browser_options = "-profile #{userdata_dir}/browser/ff/profiles/sahi0 -no-remote"
|
23
|
+
#browser_path = "C:\\Program Files\\Internet Explorer\\iexplore.exe"
|
24
|
+
#browser_options = "-nomerge"
|
25
|
+
|
23
26
|
return Sahi::Browser.new(browser_path, browser_options)
|
24
27
|
end
|
25
28
|
|
26
29
|
|
27
30
|
def test1
|
28
|
-
@browser.navigate_to("
|
31
|
+
@browser.navigate_to(@base_url + "/demo/formTest.htm")
|
29
32
|
@browser.textbox("t1").value = "aaa"
|
30
33
|
@browser.link("Back").click
|
31
34
|
@browser.link("Table Test").click
|
@@ -53,339 +56,363 @@ class SahiDriverTest < Test::Unit::TestCase
|
|
53
56
|
end
|
54
57
|
|
55
58
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
def test_fetch()
|
60
|
+
@browser.navigate_to(@base_url + "/demo/formTest.htm")
|
61
|
+
assert_equal(@base_url + "/demo/formTest.htm", @browser.fetch("window.location.href"))
|
62
|
+
end
|
60
63
|
|
61
64
|
def test_accessors()
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
65
|
+
@browser.navigate_to(@base_url + "/demo/formTest.htm")
|
66
|
+
assert_equal("", @browser.textbox("t1").value)
|
67
|
+
assert(@browser.textbox(1).exists?)
|
68
|
+
assert(@browser.textbox("$a_dollar").exists?)
|
69
|
+
@browser.textbox("$a_dollar").value = ("adas")
|
70
|
+
assert_equal("", @browser.textbox(1).value)
|
71
|
+
assert(@browser.textarea("ta1").exists?)
|
72
|
+
assert_equal("", @browser.textarea("ta1").value)
|
73
|
+
assert(@browser.textarea(1).exists?)
|
74
|
+
assert_equal("", @browser.textarea(1).value)
|
75
|
+
assert(@browser.checkbox("c1").exists?)
|
76
|
+
assert_equal("cv1", @browser.checkbox("c1").value)
|
77
|
+
assert(@browser.checkbox(1).exists?)
|
78
|
+
assert_equal("cv2", @browser.checkbox(1).value)
|
79
|
+
assert(@browser.checkbox("c1[1]").exists?)
|
80
|
+
assert_equal("cv3", @browser.checkbox("c1[1]").value)
|
81
|
+
assert(@browser.checkbox(3).exists?)
|
82
|
+
assert_equal("", @browser.checkbox(3).value)
|
83
|
+
assert(@browser.radio("r1").exists?)
|
84
|
+
assert_equal("rv1", @browser.radio("r1").value)
|
85
|
+
assert(@browser.password("p1").exists?)
|
86
|
+
assert_equal("", @browser.password("p1").value)
|
87
|
+
assert(@browser.password(1).exists?)
|
88
|
+
assert_equal("", @browser.password(1).value)
|
89
|
+
assert(@browser.select("s1").exists?)
|
90
|
+
assert_equal("o1", @browser.select("s1").selected_text())
|
91
|
+
assert(@browser.select("s1Id[1]").exists?)
|
92
|
+
assert_equal("o1", @browser.select("s1Id[1]").selected_text())
|
93
|
+
assert(@browser.select(2).exists?)
|
94
|
+
assert_equal("o1", @browser.select(2).selected_text())
|
95
|
+
assert(@browser.button("button value").exists?)
|
96
|
+
assert(@browser.button("btnName[1]").exists?)
|
97
|
+
assert(@browser.button("btnId[2]").exists?)
|
98
|
+
assert(@browser.button(3).exists?)
|
99
|
+
assert(@browser.submit("Add").exists?)
|
100
|
+
assert(@browser.submit("submitBtnName[1]").exists?)
|
101
|
+
assert(@browser.submit("submitBtnId[2]").exists?)
|
102
|
+
assert(@browser.submit(3).exists?)
|
103
|
+
assert(@browser.image("imageAlt1").exists?)
|
104
|
+
assert(@browser.image("imageId1[1]").exists?)
|
105
|
+
assert(@browser.image(2).exists?)
|
106
|
+
assert(!@browser.link("Back22").exists?)
|
107
|
+
assert(@browser.link("Back").exists?)
|
108
|
+
assert(@browser.accessor("document.getElementById('s1Id')").exists?)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_select()
|
112
|
+
@browser.navigate_to(@base_url + "/demo/formTest.htm")
|
113
|
+
assert_equal("o1", @browser.select("s1Id[1]").selected_text())
|
114
|
+
@browser.select("s1Id[1]").choose("o2")
|
115
|
+
assert_equal("o2", @browser.select("s1Id[1]").selected_text())
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_set_file()
|
119
|
+
@browser.navigate_to(@base_url + "/demo/php/fileUpload.htm")
|
120
|
+
@browser.file("file").file = "scripts/demo/uploadme.txt";
|
121
|
+
@browser.submit("Submit Single").click;
|
122
|
+
assert(@browser.span("size").exists?)
|
123
|
+
assert_not_nil(@browser.span("size").text().index("0.3046875 Kb"))
|
124
|
+
assert_not_nil(@browser.span("type").text().index("Single"))
|
125
|
+
@browser.link("Back to form").click;
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_multi_file_upload()
|
129
|
+
@browser.navigate_to(@base_url + "/demo/php/fileUpload.htm")
|
130
|
+
@browser.file("file[]").file = "scripts/demo/uploadme.txt";
|
131
|
+
@browser.file("file[]").file = "scripts/demo/uploadme2.txt";
|
132
|
+
@browser.submit("Submit Array").click;
|
133
|
+
assert_not_nil(@browser.span("type").text().index("Array"))
|
134
|
+
assert_not_nil(@browser.span("file").text().index("uploadme.txt"))
|
135
|
+
assert_not_nil(@browser.span("size").text().index("0.3046875 Kb"))
|
136
|
+
|
137
|
+
assert_not_nil(@browser.span("file[1]").text().index("uploadme2.txt"))
|
138
|
+
assert_not_nil(@browser.span("size[1]").text().index("0.32421875 Kb"))
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_clicks()
|
142
|
+
@browser.navigate_to(@base_url + "/demo/formTest.htm")
|
143
|
+
assert_not_nil(@browser.checkbox("c1"))
|
144
|
+
@browser.checkbox("c1").click;
|
145
|
+
assert_equal("true", @browser.checkbox("c1").fetch("checked"))
|
146
|
+
@browser.checkbox("c1").click;
|
147
|
+
assert_equal("false", @browser.checkbox("c1").fetch("checked"))
|
148
|
+
|
149
|
+
assert_not_nil(@browser.radio("r1"))
|
150
|
+
@browser.radio("r1").click;
|
151
|
+
assert_equal("true", @browser.radio("r1").fetch("checked"))
|
152
|
+
assert(@browser.radio("r1").checked?)
|
153
|
+
assert(!@browser.radio("r1[1]").checked?)
|
154
|
+
@browser.radio("r1[1]").click;
|
155
|
+
assert_equal("false", @browser.radio("r1").fetch("checked"))
|
156
|
+
assert(@browser.radio("r1[1]").checked?)
|
157
|
+
assert(!@browser.radio("r1").checked?)
|
158
|
+
end
|
107
159
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
@browser.link("Back to form").click;
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_multi_file_upload()
|
126
|
-
@browser.navigate_to(@base_url + "/demo/php/fileUpload.htm")
|
127
|
-
@browser.file("file[]").file = "D:/sahi/sf/sahi_993/userdata/scripts/demo/uploadme.txt";
|
128
|
-
@browser.file("file[]").file = "D:/sahi/sf/sahi_993/userdata/scripts/demo/uploadme2.txt";
|
129
|
-
@browser.submit("Submit Array").click;
|
130
|
-
assert_not_nil(@browser.span("type").text().index("Array"))
|
131
|
-
assert_not_nil(@browser.span("file").text().index("uploadme.txt"))
|
132
|
-
assert_not_nil(@browser.span("size").text().index("0.3046875 Kb"))
|
133
|
-
|
134
|
-
assert_not_nil(@browser.span("file[1]").text().index("uploadme2.txt"))
|
135
|
-
assert_not_nil(@browser.span("size[1]").text().index("0.32421875 Kb"))
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_clicks()
|
139
|
-
@browser.navigate_to(@base_url + "/demo/formTest.htm")
|
140
|
-
assert_not_nil(@browser.checkbox("c1"))
|
141
|
-
@browser.checkbox("c1").click;
|
142
|
-
assert_equal("true", @browser.checkbox("c1").fetch("checked"))
|
143
|
-
@browser.checkbox("c1").click;
|
144
|
-
assert_equal("false", @browser.checkbox("c1").fetch("checked"))
|
145
|
-
|
146
|
-
assert_not_nil(@browser.radio("r1"))
|
147
|
-
@browser.radio("r1").click;
|
148
|
-
assert_equal("true", @browser.radio("r1").fetch("checked"))
|
149
|
-
assert(@browser.radio("r1").checked())
|
150
|
-
assert(!@browser.radio("r1[1]").checked())
|
151
|
-
@browser.radio("r1[1]").click;
|
152
|
-
assert_equal("false", @browser.radio("r1").fetch("checked"))
|
153
|
-
assert(@browser.radio("r1[1]").checked())
|
154
|
-
assert(!@browser.radio("r1").checked())
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_links()
|
158
|
-
@browser.navigate_to(@base_url + "/demo/index.htm")
|
159
|
-
@browser.link("Link Test").click;
|
160
|
-
@browser.link("linkByContent").click;
|
161
|
-
@browser.link("Back").click;
|
162
|
-
@browser.link("link with return true").click;
|
163
|
-
assert(@browser.textarea("ta1").exists?)
|
164
|
-
assert_equal("", @browser.textarea("ta1").value)
|
165
|
-
@browser.link("Back").click;
|
166
|
-
@browser.link("Link Test").click;
|
167
|
-
@browser.link("link with return false").click;
|
168
|
-
assert(@browser.textbox("t1").exists?)
|
169
|
-
assert_equal("formTest link with return false", @browser.textbox("t1").value)
|
170
|
-
assert(@browser.link("linkByContent").exists?)
|
160
|
+
def test_links()
|
161
|
+
@browser.navigate_to(@base_url + "/demo/index.htm")
|
162
|
+
@browser.link("Link Test").click;
|
163
|
+
@browser.link("linkByContent").click;
|
164
|
+
@browser.link("Back").click;
|
165
|
+
@browser.link("link with return true").click;
|
166
|
+
assert(@browser.textarea("ta1").exists?)
|
167
|
+
assert_equal("", @browser.textarea("ta1").value)
|
168
|
+
@browser.link("Back").click;
|
169
|
+
@browser.link("Link Test").click;
|
170
|
+
@browser.link("link with return false").click;
|
171
|
+
assert(@browser.textbox("t1").exists?)
|
172
|
+
assert_equal("formTest link with return false", @browser.textbox("t1").value)
|
173
|
+
assert(@browser.link("linkByContent").exists?)
|
171
174
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
175
|
+
@browser.link("link with returnValue=false").click;
|
176
|
+
assert(@browser.textbox("t1").exists?)
|
177
|
+
assert_equal("formTest link with returnValue=false", @browser.textbox("t1").value)
|
178
|
+
@browser.link("added handler using js").click;
|
179
|
+
assert(@browser.textbox("t1").exists?)
|
180
|
+
assert_equal("myFn called", @browser.textbox("t1").value)
|
181
|
+
@browser.textbox("t1").value = ("")
|
182
|
+
@browser.image("imgWithLink").click;
|
183
|
+
@browser.link("Link Test").click;
|
184
|
+
@browser.image("imgWithLinkNoClick").click;
|
185
|
+
assert(@browser.textbox("t1").exists?)
|
186
|
+
assert_equal("myFn called", @browser.textbox("t1").value)
|
187
|
+
@browser.link("Back").click;
|
188
|
+
end
|
186
189
|
|
187
190
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
191
|
+
def test_popup_title_name_mix()
|
192
|
+
@browser.navigate_to(@base_url + "/demo/index.htm")
|
193
|
+
@browser.link("Window Open Test").click;
|
194
|
+
@browser.link("Window Open Test With Title").click;
|
195
|
+
@browser.link("Table Test").click;
|
196
|
+
|
197
|
+
popup_popwin = @browser.popup("popWin")
|
198
|
+
|
199
|
+
popup_popwin.link("Link Test").click;
|
200
|
+
@browser.link("Back").click;
|
201
|
+
|
202
|
+
popup_with_title = @browser.popup("With Title")
|
203
|
+
|
204
|
+
popup_with_title.link("Form Test").click;
|
205
|
+
@browser.link("Table Test").click;
|
206
|
+
popup_with_title.textbox("t1").value = ("d")
|
207
|
+
@browser.link("Back").click;
|
208
|
+
popup_with_title.textbox(1).value = ("e")
|
209
|
+
@browser.link("Table Test").click;
|
210
|
+
popup_with_title.textbox("name").value = ("f")
|
211
|
+
assert_not_nil(popup_popwin.link("linkByHtml").exists?)
|
209
212
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
213
|
+
assert_not_nil(@browser.cell("CellWithId"))
|
214
|
+
assert_equal("Cell with id", @browser.cell("CellWithId").text)
|
215
|
+
popup_with_title.link("Break Frames").click;
|
216
|
+
|
217
|
+
popupSahiTests = @browser.popup("Sahi Tests")
|
218
|
+
popupSahiTests.close()
|
219
|
+
|
220
|
+
popup_popwin.link("Break Frames").click;
|
221
|
+
popup_popwin.close()
|
222
|
+
@browser.link("Back").click;
|
223
|
+
end
|
221
224
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
225
|
+
|
226
|
+
def test_in()
|
227
|
+
@browser.navigate_to(@base_url + "/demo/tableTest.htm")
|
228
|
+
assert_equal("111", @browser.textarea("ta").near(@browser.cell("a1")).value)
|
229
|
+
assert_equal("222", @browser.textarea("ta").near(@browser.cell("a2")).value)
|
230
|
+
@browser.link("Go back").in(@browser.cell("a1").parent_node()).click;
|
231
|
+
assert(@browser.link("Link Test").exists?)
|
232
|
+
end
|
230
233
|
|
231
234
|
def test_exists()
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
235
|
+
@browser.navigate_to(@base_url + "/demo/index.htm")
|
236
|
+
assert(@browser.link("Link Test").exists?)
|
237
|
+
assert(!@browser.link("Link Test NonExistent").exists?)
|
238
|
+
end
|
239
|
+
|
240
|
+
def alert1(message)
|
241
|
+
@browser.navigate_to(@base_url + "/demo/alertTest.htm")
|
242
|
+
@browser.textbox("t1").value = ("Message " + message)
|
243
|
+
@browser.button("Click For Alert").click;
|
244
|
+
@browser.navigate_to("/demo/alertTest.htm")
|
245
|
+
sleep(1)
|
246
|
+
assert_equal("Message " + message, @browser.last_alert())
|
247
|
+
@browser.clear_last_alert()
|
248
|
+
assert_nil(@browser.last_alert())
|
249
|
+
end
|
247
250
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
251
|
+
def test_alert()
|
252
|
+
alert1("One")
|
253
|
+
alert1("Two")
|
254
|
+
alert1("Three")
|
255
|
+
@browser.button("Click For Multiline Alert").click;
|
256
|
+
assert_equal("You must correct the following Errors:\nYou must select a messaging price plan.\nYou must select an international messaging price plan.\nYou must enter a value for the Network Lookup Charge", @browser.last_alert())
|
257
|
+
end
|
255
258
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
259
|
+
def test_confirm()
|
260
|
+
@browser.navigate_to(@base_url + "/demo/confirmTest.htm")
|
261
|
+
@browser.expect_confirm("Some question?", true)
|
262
|
+
@browser.button("Click For Confirm").click;
|
263
|
+
assert_equal("oked", @browser.textbox("t1").value)
|
264
|
+
@browser.navigate_to("/demo/confirmTest.htm")
|
265
|
+
sleep(1)
|
266
|
+
assert_equal("Some question?", @browser.last_confirm())
|
267
|
+
@browser.clear_last_confirm()
|
268
|
+
assert_nil(@browser.last_confirm())
|
266
269
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
270
|
+
@browser.expect_confirm("Some question?", false)
|
271
|
+
@browser.button("Click For Confirm").click;
|
272
|
+
assert_equal("canceled", @browser.textbox("t1").value)
|
273
|
+
assert_equal("Some question?", @browser.last_confirm())
|
274
|
+
@browser.clear_last_confirm()
|
275
|
+
assert_nil(@browser.last_confirm())
|
273
276
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
277
|
+
@browser.expect_confirm("Some question?", true)
|
278
|
+
@browser.button("Click For Confirm").click;
|
279
|
+
assert_equal("oked", @browser.textbox("t1").value)
|
280
|
+
assert_equal("Some question?", @browser.last_confirm())
|
281
|
+
@browser.clear_last_confirm()
|
282
|
+
assert_nil(@browser.last_confirm())
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_prompt()
|
286
|
+
@browser.navigate_to(@base_url + "/demo/promptTest.htm")
|
287
|
+
@browser.expect_prompt("Some prompt?", "abc")
|
288
|
+
@browser.button("Click For Prompt").click;
|
289
|
+
assert_not_nil(@browser.textbox("t1"))
|
290
|
+
assert_equal("abc", @browser.textbox("t1").value)
|
291
|
+
@browser.navigate_to("/demo/promptTest.htm")
|
292
|
+
@browser.waitFor(2000)
|
293
|
+
assert_equal("Some prompt?", @browser.last_prompt())
|
294
|
+
@browser.clear_last_prompt()
|
295
|
+
assert_nil(@browser.last_prompt())
|
296
|
+
end
|
294
297
|
|
295
298
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
299
|
+
def test_visible
|
300
|
+
@browser.navigate_to(@base_url + "/demo/index.htm")
|
301
|
+
@browser.link("Visible Test").click;
|
302
|
+
assert(@browser.spandiv("using display").visible?)
|
300
303
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
304
|
+
@browser.button("Display none").click;
|
305
|
+
assert(!@browser.spandiv("using display").visible?)
|
306
|
+
@browser.button("Display block").click;
|
307
|
+
assert(@browser.spandiv("using display").visible?)
|
305
308
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
309
|
+
@browser.button("Display none").click;
|
310
|
+
assert(!@browser.spandiv("using display").visible?)
|
311
|
+
@browser.button("Display inline").click;
|
312
|
+
assert(@browser.spandiv("using display").visible?)
|
310
313
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
314
|
+
assert(@browser.spandiv("using visibility").visible?)
|
315
|
+
@browser.button("Visibility hidden").click;
|
316
|
+
assert(!@browser.spandiv("using visibility").visible?)
|
317
|
+
@browser.button("Visibility visible").click;
|
318
|
+
assert(@browser.spandiv("using visibility").visible?)
|
316
319
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
def test_title()
|
350
|
-
@browser.navigate_to(@base_url + "/demo/index.htm")
|
351
|
-
assert_equal("Sahi Tests", @browser.title)
|
352
|
-
@browser.link("Form Test").click;
|
353
|
-
assert_equal("Form Test", @browser.title)
|
354
|
-
@browser.link("Back").click;
|
355
|
-
@browser.link("Window Open Test With Title").click;
|
356
|
-
assert_equal("With Title", @browser.popup("With Title").title)
|
357
|
-
end
|
358
|
-
|
359
|
-
def test_area()
|
360
|
-
@browser.navigate_to(@base_url + "/demo/map.htm")
|
361
|
-
@browser.navigate_to("map.htm")
|
362
|
-
assert(@browser.area("Record").exists?)
|
363
|
-
assert(@browser.area("Playback").exists?)
|
364
|
-
assert(@browser.area("Info").exists?)
|
365
|
-
assert(@browser.area("Circular").exists?)
|
366
|
-
@browser.area("Record").mouse_over()
|
367
|
-
assert_equal("Record", @browser.div("output").text)
|
368
|
-
@browser.button("Clear").mouse_over()
|
369
|
-
assert_equal("", @browser.div("output").text)
|
370
|
-
@browser.area("Record").click;
|
371
|
-
assert(@browser.link("linkByContent").exists?)
|
372
|
-
#@browser.navigate_to("map.htm")
|
373
|
-
end
|
320
|
+
assert(!@browser.byId("nestedBlockInNone").visible?)
|
321
|
+
assert(!@browser.byId("absoluteNestedBlockInNone").visible?)
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_check()
|
325
|
+
@browser.navigate_to(@base_url + "/demo/")
|
326
|
+
@browser.link("Form Test").click;
|
327
|
+
assert_equal("false", @browser.checkbox("c1").fetch("checked"))
|
328
|
+
assert(!@browser.checkbox("c1").checked?)
|
329
|
+
@browser.checkbox("c1").check()
|
330
|
+
assert_equal("true", @browser.checkbox("c1").fetch("checked"))
|
331
|
+
assert(@browser.checkbox("c1").checked?)
|
332
|
+
@browser.checkbox("c1").check()
|
333
|
+
assert_equal("true", @browser.checkbox("c1").fetch("checked"))
|
334
|
+
@browser.checkbox("c1").uncheck()
|
335
|
+
assert_equal("false", @browser.checkbox("c1").fetch("checked"))
|
336
|
+
@browser.checkbox("c1").uncheck()
|
337
|
+
assert_equal("false", @browser.checkbox("c1").fetch("checked"))
|
338
|
+
@browser.checkbox("c1").click;
|
339
|
+
assert_equal("true", @browser.checkbox("c1").fetch("checked"))
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_focus()
|
343
|
+
@browser.navigate_to(@base_url + "/demo/focusTest.htm")
|
344
|
+
@browser.textbox("t2").focus()
|
345
|
+
assert_equal("focused", @browser.textbox("t1").value)
|
346
|
+
@browser.textbox("t2").remove_focus()
|
347
|
+
assert_equal("not focused", @browser.textbox("t1").value)
|
348
|
+
@browser.textbox("t2").focus()
|
349
|
+
assert_equal("focused", @browser.textbox("t1").value)
|
350
|
+
end
|
374
351
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
352
|
+
def test_title()
|
353
|
+
@browser.navigate_to(@base_url + "/demo/index.htm")
|
354
|
+
assert_equal("Sahi Tests", @browser.title)
|
355
|
+
@browser.link("Form Test").click;
|
356
|
+
assert_equal("Form Test", @browser.title)
|
357
|
+
@browser.link("Back").click;
|
358
|
+
@browser.link("Window Open Test With Title").click;
|
359
|
+
assert_equal("With Title", @browser.popup("With Title").title)
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_area()
|
363
|
+
@browser.navigate_to(@base_url + "/demo/map.htm")
|
364
|
+
@browser.navigate_to("map.htm")
|
365
|
+
assert(@browser.area("Record").exists?)
|
366
|
+
assert(@browser.area("Playback").exists?)
|
367
|
+
assert(@browser.area("Info").exists?)
|
368
|
+
assert(@browser.area("Circular").exists?)
|
369
|
+
@browser.area("Record").mouse_over()
|
370
|
+
assert_equal("Record", @browser.div("output").text)
|
371
|
+
@browser.button("Clear").mouse_over()
|
372
|
+
assert_equal("", @browser.div("output").text)
|
373
|
+
@browser.area("Record").click;
|
374
|
+
assert(@browser.link("linkByContent").exists?)
|
375
|
+
#@browser.navigate_to("map.htm")
|
376
|
+
end
|
383
377
|
|
384
|
-
|
385
|
-
|
378
|
+
def test_dragdrop()
|
379
|
+
@browser.navigate_to("http://www.snook.ca/technical/mootoolsdragdrop/")
|
380
|
+
@browser.div("Drag me").drag_and_drop_on(@browser.div("Item 2"))
|
381
|
+
assert @browser.div("dropped").exists?
|
382
|
+
assert @browser.div("Item 1").exists?
|
383
|
+
assert @browser.div("Item 3").exists?
|
384
|
+
assert @browser.div("Item 4").exists?
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_wait()
|
388
|
+
@browser.navigate_to(@base_url + "/demo/waitCondition1.htm")
|
386
389
|
@browser.wait(15) {"populated" == @browser.textbox("t1").value}
|
387
|
-
|
388
|
-
|
390
|
+
assert_equal("populated", @browser.textbox("t1").value)
|
391
|
+
end
|
392
|
+
|
393
|
+
def test_google()
|
394
|
+
@browser.navigate_to("http://www.google.com")
|
395
|
+
@browser.textbox("q").value = "sahi forums"
|
396
|
+
@browser.submit("Google Search").click
|
397
|
+
@browser.link("Sahi - Web Automation and Test Tool").click
|
398
|
+
@browser.link("Login").click
|
399
|
+
assert @browser.textbox("req_username").visible?
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_dblclick()
|
403
|
+
@browser.navigate_to("#{@base_url}/demo/clicks.htm")
|
404
|
+
@browser.div("dbl click me").dblclick
|
405
|
+
assert_equal("[DOUBLE_CLICK]", @browser.textarea("t2").value)
|
406
|
+
@browser.button("Clear").click
|
407
|
+
end
|
408
|
+
|
409
|
+
def test_right_click()
|
410
|
+
@browser.navigate_to("#{@base_url}/demo/clicks.htm")
|
411
|
+
@browser.div("right click me").right_click
|
412
|
+
assert_equal("[RIGHT_CLICK]", @browser.textarea("t2").value)
|
413
|
+
@browser.button("Clear").click
|
414
|
+
end
|
415
|
+
|
389
416
|
|
390
417
|
end
|
391
418
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Narayan Raman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-30 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -45,7 +45,10 @@ dependencies:
|
|
45
45
|
version: 0.1.1
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
|
-
description:
|
48
|
+
description: |-
|
49
|
+
Ruby driver for Sahi (http://sahi.co.in/). Sahi is a web automation tool.
|
50
|
+
Sahi runs as a proxy, and the browser needs to be configured to use Sahi's proxy.
|
51
|
+
The browser can then be driven via the Sahi Ruby driver.
|
49
52
|
email: support@sahi.co.in
|
50
53
|
executables: []
|
51
54
|
|