rsel 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/docs/examples.md +6 -6
- data/docs/history.md +9 -0
- data/docs/scoping.md +10 -6
- data/docs/todo.md +0 -2
- data/docs/usage.md +18 -10
- data/lib/rsel/exceptions.rb +1 -0
- data/lib/rsel/selenium_test.rb +123 -70
- data/rsel.gemspec +1 -1
- data/spec/selenium_test_spec.rb +95 -5
- data/test/views/index.erb +1 -0
- data/test/views/readonly_form.erb +62 -0
- metadata +5 -4
data/docs/examples.md
CHANGED
@@ -12,7 +12,7 @@ like to execute these examples.
|
|
12
12
|
Links
|
13
13
|
-------------
|
14
14
|
|
15
|
-
| script | selenium test |
|
15
|
+
| script | selenium test | http://localhost:8070 |
|
16
16
|
| Open browser |
|
17
17
|
| Maximize browser |
|
18
18
|
| Visit | / |
|
@@ -32,7 +32,7 @@ Links
|
|
32
32
|
Buttons
|
33
33
|
-------------
|
34
34
|
|
35
|
-
| script | selenium test |
|
35
|
+
| script | selenium test | http://localhost:8070 |
|
36
36
|
| Open browser |
|
37
37
|
| Maximize browser |
|
38
38
|
| Visit | /form |
|
@@ -49,7 +49,7 @@ Buttons
|
|
49
49
|
Checkboxes
|
50
50
|
-------------
|
51
51
|
|
52
|
-
| script | selenium test |
|
52
|
+
| script | selenium test | http://localhost:8070 |
|
53
53
|
| Open browser |
|
54
54
|
| Maximize browser |
|
55
55
|
| Visit | /form |
|
@@ -67,7 +67,7 @@ Checkboxes
|
|
67
67
|
Dropdowns
|
68
68
|
-------------
|
69
69
|
|
70
|
-
| script | selenium test |
|
70
|
+
| script | selenium test | http://localhost:8070 |
|
71
71
|
| Open browser |
|
72
72
|
| Maximize browser |
|
73
73
|
| Visit | /form |
|
@@ -84,7 +84,7 @@ Dropdowns
|
|
84
84
|
Radiobuttons
|
85
85
|
-------------
|
86
86
|
|
87
|
-
| script | selenium test |
|
87
|
+
| script | selenium test | http://localhost:8070 |
|
88
88
|
| Open browser |
|
89
89
|
| Maximize browser |
|
90
90
|
| Visit | /form |
|
@@ -100,7 +100,7 @@ Radiobuttons
|
|
100
100
|
Tables
|
101
101
|
-------------
|
102
102
|
|
103
|
-
| script | selenium test |
|
103
|
+
| script | selenium test | http://localhost:8070 |
|
104
104
|
| Open browser |
|
105
105
|
| Maximize browser |
|
106
106
|
| Visit | /table |
|
data/docs/history.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
Rsel History
|
2
2
|
============
|
3
3
|
|
4
|
+
0.0.7
|
5
|
+
-----
|
6
|
+
|
7
|
+
- Indicate pass/fail status for Selenium::Client::Driver wrapped methods
|
8
|
+
- Allow passing stop_on_error to SeleniumTest constructor
|
9
|
+
- Auto-strip HTML in URL passed to constructor
|
10
|
+
- Button, field, checkbox, and radiobutton edits fail on disabled inputs
|
11
|
+
|
12
|
+
|
4
13
|
0.0.6
|
5
14
|
-----
|
6
15
|
|
data/docs/scoping.md
CHANGED
@@ -85,13 +85,17 @@ beginning of your table, otherwise the hash syntax will be interpreted
|
|
85
85
|
literally, instead of as an embedded hash.
|
86
86
|
|
87
87
|
This means you will need to manually escape any cells in your table that
|
88
|
-
contain URLs, email addresses, or other auto-interpreted text
|
88
|
+
contain URLs, email addresses, or other auto-interpreted text. For example,
|
89
|
+
email addresses normally have HTML added by FitNesse; you'll have to escape
|
90
|
+
those so they'll be treated as literal text:
|
89
91
|
|
90
|
-
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
| Click | !-epierce@example.com-! | link | !{within:footer} |
|
93
|
+
|
94
|
+
The only exception to this is the URL argument provided on the first row of the
|
95
|
+
table; even if FitNesse adds HTML markup to this, the `SeleniumTest` constructor
|
96
|
+
is smart enough to ignore it, so you can still do this:
|
97
|
+
|
98
|
+
| script | selenium test | http://my.site.com | !{port:4445} |
|
95
99
|
|
96
100
|
Another important thing to note is that due to the way FitNesse Slim script
|
97
101
|
tables are evaluated, the scoping hash must be added after a cell that contains
|
data/docs/todo.md
CHANGED
@@ -5,8 +5,6 @@ To-do list
|
|
5
5
|
only support true/false results, with no clear way to report on what went
|
6
6
|
wrong (aside from raising an exception, which even then curiously does not
|
7
7
|
mark the step as failed)
|
8
|
-
- Find a way to abort a test if a step fails (will probably require more
|
9
|
-
hacking on rubyslim)
|
10
8
|
- Verify the presence of images, allow clicking on images
|
11
9
|
- Create a Selenium IDE plugin to generate FitNesse-formatted output for
|
12
10
|
recorded scripts
|
data/docs/usage.md
CHANGED
@@ -6,14 +6,14 @@ tests in them. For instance, continuing with the example from
|
|
6
6
|
[Installation](install.md), your `SeleniumTests.LoginTest` might look like
|
7
7
|
this:
|
8
8
|
|
9
|
-
|
10
|
-
| Open browser
|
11
|
-
| Fill in | Username | with | castle
|
12
|
-
| Fill in | Password | with | beckett
|
13
|
-
| Click button | Log in
|
14
|
-
| Page loads in | 5 | seconds or less
|
15
|
-
| See | Logged in as castle
|
16
|
-
| Close browser
|
9
|
+
| script | selenium test | http://www.mysite.com |
|
10
|
+
| Open browser |
|
11
|
+
| Fill in | Username | with | castle |
|
12
|
+
| Fill in | Password | with | beckett |
|
13
|
+
| Click button | Log in |
|
14
|
+
| Page loads in | 5 | seconds or less |
|
15
|
+
| See | Logged in as castle |
|
16
|
+
| Close browser |
|
17
17
|
|
18
18
|
Before running a test, you must make sure you have Selenium Server installed and running.
|
19
19
|
Download [selenium-server-standalone-x.x.x.jar](http://seleniumhq.org/download/), and start
|
@@ -25,10 +25,18 @@ By default, the server runs on port 4444, and this is the port that Rsel uses
|
|
25
25
|
unless you tell it otherwise. Rsel also assumes that you're running
|
26
26
|
selenium-server on your localhost (that is, the same host where FitNesse is
|
27
27
|
running); if you need to use a different host or port number, pass those as
|
28
|
-
|
28
|
+
a hash argument to the first line of the table. For example, if you are running
|
29
29
|
selenium-server on `my.selenium.host`, port `4455`, do this:
|
30
30
|
|
31
|
-
|
31
|
+
| script | selenium test | http://www.mysite.com | !{host:my.selenium.host, port:4455} |
|
32
|
+
|
33
|
+
Another useful argument to pass in this hash is `stop_on_error`, which causes
|
34
|
+
the test to be aborted whenever any failure occurs:
|
35
|
+
|
36
|
+
| script | selenium test | http://www.mysite.com | !{stop_on_error:true} |
|
37
|
+
|
38
|
+
By default, when an error occurs, the failing step is simply colored red, and
|
39
|
+
the test continues. With `stop_on_error` set, an exception will be raised.
|
32
40
|
|
33
41
|
The first argument after `selenium test` is the URL of the site you will be testing.
|
34
42
|
This URL is loaded when you call `Open browser`, and all steps that follow are
|
data/lib/rsel/exceptions.rb
CHANGED
data/lib/rsel/selenium_test.rb
CHANGED
@@ -27,26 +27,41 @@ module Rsel
|
|
27
27
|
# Initialize a test, connecting to the given Selenium server.
|
28
28
|
#
|
29
29
|
# @param [String] url
|
30
|
-
# Full URL, including http://, of the system under test
|
31
|
-
#
|
30
|
+
# Full URL, including http://, of the system under test. Any
|
31
|
+
# HTML tags around the URL will be stripped.
|
32
|
+
# @param [Hash] options
|
33
|
+
# Additional configuration settings
|
34
|
+
#
|
35
|
+
# @option options [String] :host
|
32
36
|
# IP address or hostname where selenium-server is running
|
33
|
-
# @
|
37
|
+
# @option options [String] :port
|
34
38
|
# Port number of selenium-server
|
35
|
-
# @
|
39
|
+
# @option options [String] :browser
|
36
40
|
# Which browser to test with
|
41
|
+
# @option options [String, Boolean] :stop_on_error
|
42
|
+
# `true` or `'true'` to raise an exception when a step fails,
|
43
|
+
# `false` or `'false'` to simply return false when a step fails
|
37
44
|
#
|
38
45
|
# @example
|
39
46
|
# | script | selenium test | http://site.to.test/ |
|
40
|
-
# | script | selenium test | http://site.to.test/ | 192.168.0.3 |
|
47
|
+
# | script | selenium test | http://site.to.test/ | !{host:192.168.0.3} |
|
48
|
+
# | script | selenium test | http://site.to.test/ | !{host:192.168.0.3, port:4445} |
|
49
|
+
# | script | selenium test | http://site.to.test/ | !{stop_on_error:true} |
|
41
50
|
#
|
42
|
-
def initialize(url,
|
43
|
-
|
51
|
+
def initialize(url, options={})
|
52
|
+
# Strip HTML tags from URL
|
53
|
+
@url = url.gsub(/<\/?[^>]*>/, '')
|
44
54
|
@browser = Selenium::Client::Driver.new(
|
45
|
-
:host => host,
|
46
|
-
:port => port,
|
47
|
-
:browser => browser,
|
48
|
-
:url => url)
|
49
|
-
|
55
|
+
:host => options[:host] || 'localhost',
|
56
|
+
:port => options[:port] || 4444,
|
57
|
+
:browser => options[:browser] || '*firefox',
|
58
|
+
:url => @url)
|
59
|
+
# Accept Booleans or strings, case-insensitive
|
60
|
+
if options[:stop_on_error].to_s =~ /true/i
|
61
|
+
@stop_on_error = true
|
62
|
+
else
|
63
|
+
@stop_on_error = false
|
64
|
+
end
|
50
65
|
end
|
51
66
|
|
52
67
|
attr_reader :url, :browser, :stop_on_error
|
@@ -97,7 +112,7 @@ module Rsel
|
|
97
112
|
# | Visit | /software |
|
98
113
|
#
|
99
114
|
def visit(path_or_url)
|
100
|
-
|
115
|
+
fail_on_exception do
|
101
116
|
@browser.open(path_or_url)
|
102
117
|
end
|
103
118
|
end
|
@@ -109,7 +124,7 @@ module Rsel
|
|
109
124
|
# | Click back |
|
110
125
|
#
|
111
126
|
def click_back
|
112
|
-
|
127
|
+
fail_on_exception do
|
113
128
|
@browser.go_back
|
114
129
|
end
|
115
130
|
end
|
@@ -121,7 +136,7 @@ module Rsel
|
|
121
136
|
# | Refresh page |
|
122
137
|
#
|
123
138
|
def refresh_page
|
124
|
-
|
139
|
+
fail_on_exception do
|
125
140
|
@browser.refresh
|
126
141
|
end
|
127
142
|
end
|
@@ -243,7 +258,8 @@ module Rsel
|
|
243
258
|
end
|
244
259
|
|
245
260
|
|
246
|
-
# Type a value into the given field.
|
261
|
+
# Type a value into the given field. Passes if the field exists and is
|
262
|
+
# editable. Fails if the field is not found, or is not editable.
|
247
263
|
#
|
248
264
|
# @param [String] text
|
249
265
|
# What to type into the field
|
@@ -257,13 +273,15 @@ module Rsel
|
|
257
273
|
# | Type | Dale | into | First name | field | !{within:contact} |
|
258
274
|
#
|
259
275
|
def type_into_field(text, locator, scope={})
|
260
|
-
|
261
|
-
|
276
|
+
field = loc(locator, 'field', scope)
|
277
|
+
fail_on_exception do
|
278
|
+
ensure_editable(field) && @browser.type(field, text)
|
262
279
|
end
|
263
280
|
end
|
264
281
|
|
265
282
|
|
266
|
-
# Fill in a field with the given text.
|
283
|
+
# Fill in a field with the given text. Passes if the field exists and is
|
284
|
+
# editable. Fails if the field is not found, or is not editable.
|
267
285
|
#
|
268
286
|
# @param [String] locator
|
269
287
|
# Label, name, or id of the field you want to type into
|
@@ -280,9 +298,8 @@ module Rsel
|
|
280
298
|
end
|
281
299
|
|
282
300
|
|
283
|
-
# Verify that a text field contains the given text.
|
284
|
-
#
|
285
|
-
# expected value is in there somewhere.
|
301
|
+
# Verify that a text field contains the given text. The field may include
|
302
|
+
# additional text, as long as the expected value is in there somewhere.
|
286
303
|
#
|
287
304
|
# @param [String] locator
|
288
305
|
# Label, name, or id of the field you want to inspect
|
@@ -303,8 +320,8 @@ module Rsel
|
|
303
320
|
end
|
304
321
|
|
305
322
|
|
306
|
-
# Verify that a text field's value equals the given text.
|
307
|
-
#
|
323
|
+
# Verify that a text field's value equals the given text. The value must
|
324
|
+
# match exactly.
|
308
325
|
#
|
309
326
|
# @param [String] locator
|
310
327
|
# Label, name, or id of the field you want to inspect
|
@@ -337,7 +354,7 @@ module Rsel
|
|
337
354
|
# | Click; | Logout | !{within:header} |
|
338
355
|
#
|
339
356
|
def click(locator, scope={})
|
340
|
-
|
357
|
+
fail_on_exception do
|
341
358
|
@browser.click(loc(locator, 'link_or_button', scope))
|
342
359
|
end
|
343
360
|
end
|
@@ -357,14 +374,15 @@ module Rsel
|
|
357
374
|
# | Click | Edit | link | !{in_row:Eric} |
|
358
375
|
#
|
359
376
|
def click_link(locator, scope={})
|
360
|
-
|
377
|
+
fail_on_exception do
|
361
378
|
@browser.click(loc(locator, 'link', scope))
|
362
379
|
end
|
363
380
|
end
|
364
381
|
alias_method :follow, :click_link
|
365
382
|
|
366
383
|
|
367
|
-
# Press a button.
|
384
|
+
# Press a button. Passes if the button exists and is not disabled.
|
385
|
+
# Fails if the button is not found, or is disabled.
|
368
386
|
#
|
369
387
|
# @param [String] locator
|
370
388
|
# Text, value, or id of the button
|
@@ -377,16 +395,17 @@ module Rsel
|
|
377
395
|
# | Click | Search | button | !{within:customers} |
|
378
396
|
#
|
379
397
|
def click_button(locator, scope={})
|
380
|
-
|
381
|
-
|
382
|
-
@browser.click(
|
398
|
+
button = loc(locator, 'button', scope)
|
399
|
+
fail_on_exception do
|
400
|
+
ensure_editable(button) && @browser.click(button)
|
383
401
|
end
|
384
402
|
end
|
385
403
|
alias_method :press, :click_button
|
386
404
|
|
387
405
|
|
388
|
-
# Enable (check) a checkbox by clicking on it.
|
389
|
-
#
|
406
|
+
# Enable (check) a checkbox by clicking on it. If the checkbox is already
|
407
|
+
# enabled, do nothing. Passes if the checkbox exists and is editable. Fails
|
408
|
+
# if the checkbox is not found, or is not editable.
|
390
409
|
#
|
391
410
|
# @param [String] locator
|
392
411
|
# Label, value, or id of the checkbox to check
|
@@ -398,15 +417,16 @@ module Rsel
|
|
398
417
|
# | Enable | Send me spam | checkbox | !{within:opt_in} |
|
399
418
|
#
|
400
419
|
def enable_checkbox(locator, scope={})
|
401
|
-
|
402
|
-
|
403
|
-
@browser.click(
|
420
|
+
cb = loc(locator, 'checkbox', scope)
|
421
|
+
fail_on_exception do
|
422
|
+
ensure_editable(cb) && checkbox_is_disabled(cb) && @browser.click(cb)
|
404
423
|
end
|
405
424
|
end
|
406
425
|
|
407
426
|
|
408
|
-
# Disable (uncheck) a checkbox by clicking on it.
|
409
|
-
#
|
427
|
+
# Disable (uncheck) a checkbox by clicking on it. If the checkbox is
|
428
|
+
# already disabled, do nothing. Passes if the checkbox exists and is
|
429
|
+
# editable. Fails if the checkbox is not found, or is not editable.
|
410
430
|
#
|
411
431
|
# @param [String] locator
|
412
432
|
# Label, value, or id of the checkbox to uncheck
|
@@ -418,9 +438,9 @@ module Rsel
|
|
418
438
|
# | Disable | Send me spam | checkbox | !{within:opt_in} |
|
419
439
|
#
|
420
440
|
def disable_checkbox(locator, scope={})
|
421
|
-
|
422
|
-
|
423
|
-
@browser.click(
|
441
|
+
cb = loc(locator, 'checkbox', scope)
|
442
|
+
fail_on_exception do
|
443
|
+
ensure_editable(cb) && checkbox_is_enabled(cb) && @browser.click(cb)
|
424
444
|
end
|
425
445
|
end
|
426
446
|
|
@@ -521,7 +541,8 @@ module Rsel
|
|
521
541
|
end
|
522
542
|
|
523
543
|
|
524
|
-
# Select a radio button.
|
544
|
+
# Select a radio button. Passes if the radio button exists and is editable.
|
545
|
+
# Fails if the radiobutton is not found, or is not editable.
|
525
546
|
#
|
526
547
|
# @param [String] locator
|
527
548
|
# Label, id, or name of the radio button to select
|
@@ -533,13 +554,16 @@ module Rsel
|
|
533
554
|
# | Select | female | radio | !{within:gender} |
|
534
555
|
#
|
535
556
|
def select_radio(locator, scope={})
|
536
|
-
|
537
|
-
|
557
|
+
radio = loc(locator, 'radio_button', scope)
|
558
|
+
fail_on_exception do
|
559
|
+
ensure_editable(radio) && @browser.click(radio)
|
538
560
|
end
|
539
561
|
end
|
540
562
|
|
541
563
|
|
542
|
-
# Select an option from a dropdown/combo box.
|
564
|
+
# Select an option from a dropdown/combo box. Passes if the dropdown exists,
|
565
|
+
# is editable, and includes the given option. Fails if the dropdown is not
|
566
|
+
# found, the option is not found, or the dropdown is not editable.
|
543
567
|
#
|
544
568
|
# @param [String] option
|
545
569
|
# The option to choose from the dropdown
|
@@ -551,8 +575,9 @@ module Rsel
|
|
551
575
|
# | Select | Tall | from dropdown | Height |
|
552
576
|
#
|
553
577
|
def select_from_dropdown(option, locator, scope={})
|
554
|
-
|
555
|
-
|
578
|
+
dropdown = loc(locator, 'select', scope)
|
579
|
+
fail_on_exception do
|
580
|
+
ensure_editable(dropdown) && @browser.select(dropdown, option)
|
556
581
|
end
|
557
582
|
end
|
558
583
|
|
@@ -626,34 +651,12 @@ module Rsel
|
|
626
651
|
# | Page loads in | 10 | seconds or less |
|
627
652
|
#
|
628
653
|
def page_loads_in_seconds_or_less(seconds)
|
629
|
-
|
654
|
+
fail_on_exception do
|
630
655
|
@browser.wait_for_page_to_load(seconds)
|
631
656
|
end
|
632
657
|
end
|
633
658
|
|
634
659
|
|
635
|
-
# Execute the given block, and return false if it raises an exception.
|
636
|
-
# Otherwise, return true. If `@stop_on_error` is true, raise a
|
637
|
-
# `StopTestStepFailed` exception instead of returning false.
|
638
|
-
#
|
639
|
-
# @example
|
640
|
-
# return_error_status do
|
641
|
-
# # some code that might raise an exception
|
642
|
-
# end
|
643
|
-
#
|
644
|
-
def return_error_status
|
645
|
-
begin
|
646
|
-
yield
|
647
|
-
rescue => e
|
648
|
-
#puts e.message
|
649
|
-
#puts e.backtrace
|
650
|
-
failure e.message
|
651
|
-
else
|
652
|
-
return true
|
653
|
-
end
|
654
|
-
end
|
655
|
-
|
656
|
-
|
657
660
|
# Invoke a missing method. If a method is called on a SeleniumTest
|
658
661
|
# instance, and that method is not explicitly defined, this method
|
659
662
|
# will check to see whether the underlying Selenium::Client::Driver
|
@@ -664,7 +667,16 @@ module Rsel
|
|
664
667
|
#
|
665
668
|
def method_missing(method, *args, &block)
|
666
669
|
if @browser.respond_to?(method)
|
667
|
-
|
670
|
+
begin
|
671
|
+
result = @browser.send(method, *args, &block)
|
672
|
+
rescue => e
|
673
|
+
failure e.message
|
674
|
+
else
|
675
|
+
# The method call succeeded; did it return true or false?
|
676
|
+
return result if [true, false].include? result
|
677
|
+
# Not a Boolean return value--assume passing
|
678
|
+
return true
|
679
|
+
end
|
668
680
|
else
|
669
681
|
super
|
670
682
|
end
|
@@ -687,6 +699,47 @@ module Rsel
|
|
687
699
|
end
|
688
700
|
|
689
701
|
|
702
|
+
private
|
703
|
+
|
704
|
+
# Execute the given block, and return false if it raises an exception.
|
705
|
+
# Otherwise, return true. If `@stop_on_error` is true, raise a
|
706
|
+
# `StopTestStepFailed` exception instead of returning false.
|
707
|
+
#
|
708
|
+
# @example
|
709
|
+
# fail_on_exception do
|
710
|
+
# # some code that might raise an exception
|
711
|
+
# end
|
712
|
+
#
|
713
|
+
def fail_on_exception
|
714
|
+
begin
|
715
|
+
yield
|
716
|
+
rescue => e
|
717
|
+
#puts e.message
|
718
|
+
#puts e.backtrace
|
719
|
+
failure e.message
|
720
|
+
else
|
721
|
+
return true
|
722
|
+
end
|
723
|
+
end
|
724
|
+
|
725
|
+
|
726
|
+
# Raise an exception if the given input is not editable.
|
727
|
+
#
|
728
|
+
# @param [String] selenium_locator
|
729
|
+
# Locator string for an input (text field, checkbox, or button) as
|
730
|
+
# understood by Selenium
|
731
|
+
#
|
732
|
+
# @since 0.0.7
|
733
|
+
#
|
734
|
+
def ensure_editable(selenium_locator)
|
735
|
+
if @browser.is_editable(selenium_locator)
|
736
|
+
return true
|
737
|
+
else
|
738
|
+
raise StopTestInputDisabled, "Input is not editable"
|
739
|
+
end
|
740
|
+
end
|
741
|
+
|
742
|
+
|
690
743
|
# Indicate a failure by returning `false` or raising an exception.
|
691
744
|
# If `@stop_on_error` is true, raise a `StopTestStepFailed` exception.
|
692
745
|
# Otherwise, simply return false.
|
data/rsel.gemspec
CHANGED
data/spec/selenium_test_spec.rb
CHANGED
@@ -97,7 +97,7 @@ describe Rsel::SeleniumTest do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
context "fails when" do
|
100
|
-
it "fails when
|
100
|
+
it "fails when text is present" do
|
101
101
|
@st.do_not_see("Welcome").should be_false
|
102
102
|
@st.do_not_see("This is a Sinatra webapp").should be_false
|
103
103
|
end
|
@@ -226,8 +226,9 @@ describe Rsel::SeleniumTest do
|
|
226
226
|
# TODO
|
227
227
|
end
|
228
228
|
|
229
|
-
it "button exists, but is
|
230
|
-
|
229
|
+
it "button exists, but is read-only" do
|
230
|
+
@st.visit("/readonly_form").should be_true
|
231
|
+
@st.click_button("Submit person form").should be_false
|
231
232
|
end
|
232
233
|
end
|
233
234
|
end
|
@@ -321,6 +322,11 @@ describe Rsel::SeleniumTest do
|
|
321
322
|
@st.type_into_field("Long story", "Life story",
|
322
323
|
:within => 'spouse_form').should be_false
|
323
324
|
end
|
325
|
+
|
326
|
+
it "field exists, but is read-only" do
|
327
|
+
@st.visit("/readonly_form").should be_true
|
328
|
+
@st.type_into_field("Eric", "First name").should be_false
|
329
|
+
end
|
324
330
|
end
|
325
331
|
end
|
326
332
|
|
@@ -419,7 +425,8 @@ describe Rsel::SeleniumTest do
|
|
419
425
|
end
|
420
426
|
|
421
427
|
it "exactly equals the text, but is not within scope" do
|
422
|
-
|
428
|
+
@st.fill_in_with("First name", "Eric", :within => "person_form")
|
429
|
+
@st.field_equals("First name", "Eric", :within => "spouse_form").should be_false
|
423
430
|
end
|
424
431
|
|
425
432
|
it "exactly equals the text, but is not in table row" do
|
@@ -444,6 +451,11 @@ describe Rsel::SeleniumTest do
|
|
444
451
|
@st.enable_checkbox("I like salami").should be_true
|
445
452
|
end
|
446
453
|
|
454
|
+
it "exists and is already checked" do
|
455
|
+
@st.enable_checkbox("I like cheese")
|
456
|
+
@st.enable_checkbox("I like cheese").should be_true
|
457
|
+
end
|
458
|
+
|
447
459
|
it "exists within scope" do
|
448
460
|
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
449
461
|
@st.enable_checkbox("I like salami", :within => "salami_checkbox").should be_true
|
@@ -484,6 +496,11 @@ describe Rsel::SeleniumTest do
|
|
484
496
|
@st.visit("/table")
|
485
497
|
@st.enable_checkbox("Like", :in_row => "Eric").should be_false
|
486
498
|
end
|
499
|
+
|
500
|
+
it "exists, but is read-only" do
|
501
|
+
@st.visit("/readonly_form").should be_true
|
502
|
+
@st.enable_checkbox("I like salami").should be_false
|
503
|
+
end
|
487
504
|
end
|
488
505
|
end
|
489
506
|
end
|
@@ -496,6 +513,11 @@ describe Rsel::SeleniumTest do
|
|
496
513
|
@st.disable_checkbox("I like salami").should be_true
|
497
514
|
end
|
498
515
|
|
516
|
+
it "exists and is already unchecked" do
|
517
|
+
@st.disable_checkbox("I like cheese")
|
518
|
+
@st.disable_checkbox("I like cheese").should be_true
|
519
|
+
end
|
520
|
+
|
499
521
|
it "exists within scope" do
|
500
522
|
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
501
523
|
@st.disable_checkbox("I like salami", :within => "preferences_form").should be_true
|
@@ -536,6 +558,11 @@ describe Rsel::SeleniumTest do
|
|
536
558
|
@st.visit("/table")
|
537
559
|
@st.disable_checkbox("Like", :in_row => "Eric").should be_false
|
538
560
|
end
|
561
|
+
|
562
|
+
it "exists, but is read-only" do
|
563
|
+
@st.visit("/readonly_form").should be_true
|
564
|
+
@st.disable_checkbox("I like cheese").should be_false
|
565
|
+
end
|
539
566
|
end
|
540
567
|
end
|
541
568
|
end
|
@@ -558,6 +585,11 @@ describe Rsel::SeleniumTest do
|
|
558
585
|
@st.enable_checkbox("Like", :in_row => "Ken").should be_true
|
559
586
|
@st.checkbox_is_enabled("Like", :in_row => "Ken").should be_true
|
560
587
|
end
|
588
|
+
|
589
|
+
it "exists and is checked, but read-only" do
|
590
|
+
@st.visit("/readonly_form").should be_true
|
591
|
+
@st.checkbox_is_enabled("I like cheese").should be_true
|
592
|
+
end
|
561
593
|
end
|
562
594
|
end
|
563
595
|
|
@@ -604,6 +636,11 @@ describe Rsel::SeleniumTest do
|
|
604
636
|
@st.disable_checkbox("Like", :in_row => "Ken").should be_true
|
605
637
|
@st.checkbox_is_disabled("Like", :in_row => "Ken").should be_true
|
606
638
|
end
|
639
|
+
|
640
|
+
it "exists and is unchecked, but read-only" do
|
641
|
+
@st.visit("/readonly_form").should be_true
|
642
|
+
@st.checkbox_is_disabled("I like salami").should be_true
|
643
|
+
end
|
607
644
|
end
|
608
645
|
end
|
609
646
|
|
@@ -666,6 +703,11 @@ describe Rsel::SeleniumTest do
|
|
666
703
|
@st.select_radio("Briefs", :within => "food").should be_false
|
667
704
|
end
|
668
705
|
|
706
|
+
it "exists, but is read-only" do
|
707
|
+
@st.visit("/readonly_form").should be_true
|
708
|
+
@st.select_radio("Boxers").should be_false
|
709
|
+
end
|
710
|
+
|
669
711
|
it "exists, but not in table row" do
|
670
712
|
# TODO
|
671
713
|
end
|
@@ -745,6 +787,11 @@ describe Rsel::SeleniumTest do
|
|
745
787
|
@st.select_from_dropdown("Obese", "Weight").should be_false
|
746
788
|
end
|
747
789
|
|
790
|
+
it "dropdown exists, but is read-only" do
|
791
|
+
@st.visit("/readonly_form").should be_true
|
792
|
+
@st.select_from_dropdown("Tall", "Height").should be_false
|
793
|
+
end
|
794
|
+
|
748
795
|
it "dropdown exists, but not within scope" do
|
749
796
|
@st.select_from_dropdown("Medium", "Weight", :within => "spouse_form").should be_false
|
750
797
|
end
|
@@ -762,6 +809,11 @@ describe Rsel::SeleniumTest do
|
|
762
809
|
@st.dropdown_includes("Height", "Tall").should be_true
|
763
810
|
@st.dropdown_includes("Weight", "Medium").should be_true
|
764
811
|
end
|
812
|
+
|
813
|
+
it "option exists in a read-only dropdown" do
|
814
|
+
@st.visit("/readonly_form").should be_true
|
815
|
+
@st.dropdown_includes("Height", "Tall").should be_true
|
816
|
+
end
|
765
817
|
end
|
766
818
|
|
767
819
|
context "fails when" do
|
@@ -785,6 +837,11 @@ describe Rsel::SeleniumTest do
|
|
785
837
|
end
|
786
838
|
end
|
787
839
|
|
840
|
+
it "option is selected in a read-only dropdown" do
|
841
|
+
@st.visit("/readonly_form").should be_true
|
842
|
+
@st.dropdown_equals("Height", "Average").should be_true
|
843
|
+
end
|
844
|
+
|
788
845
|
it "option is selected in the dropdown, within scope" do
|
789
846
|
["Short", "Average", "Tall"].each do |height|
|
790
847
|
@st.select_from_dropdown(height, "Height", :within => "spouse_form")
|
@@ -820,7 +877,7 @@ describe Rsel::SeleniumTest do
|
|
820
877
|
@st.dropdown_equals("Height", "Average").should be_false
|
821
878
|
end
|
822
879
|
|
823
|
-
it "dropdown exists, and option is selected, but not
|
880
|
+
it "dropdown exists, and option is selected, but not within scope" do
|
824
881
|
@st.select_from_dropdown("Tall", "Height", :within => "person_form")
|
825
882
|
@st.select_from_dropdown("Short", "Height", :within => "spouse_form")
|
826
883
|
@st.dropdown_equals("Height", "Tall", :within => "spouse_form").should be_false
|
@@ -1029,5 +1086,38 @@ describe Rsel::SeleniumTest do
|
|
1029
1086
|
end
|
1030
1087
|
end # stop on error
|
1031
1088
|
|
1089
|
+
context "Selenium::Client::Driver wrapper" do
|
1090
|
+
before(:each) do
|
1091
|
+
@st.visit("/form").should be_true
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
context "method returning Boolean" do
|
1095
|
+
it "passes if method returns true" do
|
1096
|
+
@st.is_element_present("id=first_name").should be_true
|
1097
|
+
@st.is_visible("id=first_name").should be_true
|
1098
|
+
@st.is_text_present("This page has some random forms").should be_true
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
it "fails if method returns false" do
|
1102
|
+
@st.is_element_present("id=bogus_id").should be_false
|
1103
|
+
@st.is_visible("id=bogus_id").should be_false
|
1104
|
+
@st.is_text_present("This text is not there").should be_false
|
1105
|
+
end
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
context "method not returning Boolean" do
|
1109
|
+
it "passes if method doesn't raise an exception" do
|
1110
|
+
@st.get_title.should be_true
|
1111
|
+
@st.mouse_over("id=first_name").should be_true
|
1112
|
+
end
|
1113
|
+
|
1114
|
+
it "fails if method raises an exception" do
|
1115
|
+
@st.double_click("id=bogus_id").should be_false
|
1116
|
+
@st.mouse_over("id=bogus_id").should be_false
|
1117
|
+
end
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
end # Selenium::Client::Driver wrapper
|
1121
|
+
|
1032
1122
|
end
|
1033
1123
|
|
data/test/views/index.erb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head><title>Rsel Test Read-only Forms</title></head>
|
4
|
+
<body>
|
5
|
+
<h1>Read-only Forms</h1>
|
6
|
+
<p>This page has some read-only form widgets to test.</p>
|
7
|
+
|
8
|
+
<div id="person_form">
|
9
|
+
<form action="/thanks" method="get">
|
10
|
+
<p>
|
11
|
+
<label for="first_name">First name</label>
|
12
|
+
<input id="first_name" type="text" disabled="disabled" />
|
13
|
+
</p>
|
14
|
+
<p>
|
15
|
+
<label for="biography">Life story</label>
|
16
|
+
<textarea id="biography" cols="80" rows="10" disabled="disabled">
|
17
|
+
</textarea>
|
18
|
+
</p>
|
19
|
+
<p>
|
20
|
+
<label for="person_height">Height</label>
|
21
|
+
<select id="person_height" disabled="disabled">
|
22
|
+
<option value="short">Short</option>
|
23
|
+
<option value="average" selected="selected">Average</option>
|
24
|
+
<option value="tall" >Tall</option>
|
25
|
+
</select>
|
26
|
+
</p>
|
27
|
+
<p><button value="submit_person_form" disabled="disabled">Submit person form</button></p>
|
28
|
+
</form>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="preferences_form">
|
32
|
+
<form action="/thanks" method="get">
|
33
|
+
<p>
|
34
|
+
<label for="favorite_colors">Favorite Colors</label>
|
35
|
+
<select id="favorite_colors" multiple="multiple" disabled="disabled">
|
36
|
+
<option value="r">Red</option>
|
37
|
+
<option value="g">Green</option>
|
38
|
+
<option value="b">Blue</option>
|
39
|
+
</select>
|
40
|
+
</p>
|
41
|
+
<p id="cheese_checkbox">
|
42
|
+
<label for="like_cheese">I like cheese</label>
|
43
|
+
<input id="like_cheese" type="checkbox" checked="checked" disabled="disabled" />
|
44
|
+
</p>
|
45
|
+
<p id="salami_checkbox">
|
46
|
+
<label for="like_salami">I like salami</label>
|
47
|
+
<input id="like_salami" type="checkbox" disabled="disabled" />
|
48
|
+
</p>
|
49
|
+
<p id="clothing">
|
50
|
+
<label for="boxers">Boxers</label>
|
51
|
+
<input id="boxers" type="radio" name="underwear" value="boxers" disabled="disabled" />
|
52
|
+
<label for="briefs">Briefs</label>
|
53
|
+
<input id="briefs" type="radio" name="underwear" value="briefs" disabled="disabled" />
|
54
|
+
</p>
|
55
|
+
<p><input type="submit" value="Save preferences" disabled="disabled" /></p>
|
56
|
+
</form>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
</body>
|
60
|
+
</html>
|
61
|
+
|
62
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcus French
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-08-
|
20
|
+
date: 2011-08-07 00:00:00 -06:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- test/views/favicon.ico.erb
|
180
180
|
- test/views/form.erb
|
181
181
|
- test/views/index.erb
|
182
|
+
- test/views/readonly_form.erb
|
182
183
|
- test/views/table.erb
|
183
184
|
- test/views/thanks.erb
|
184
185
|
has_rdoc: true
|