watir-webdriver 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.travis.yml +1 -0
- data/CHANGES.md +1693 -0
- data/Gemfile +0 -1
- data/Rakefile +22 -0
- data/lib/watir-webdriver/alert.rb +46 -0
- data/lib/watir-webdriver/aliases.rb +2 -2
- data/lib/watir-webdriver/atoms.rb +2 -2
- data/lib/watir-webdriver/atoms/README +0 -1
- data/lib/watir-webdriver/browser.rb +195 -14
- data/lib/watir-webdriver/cell_container.rb +14 -2
- data/lib/watir-webdriver/container.rb +22 -0
- data/lib/watir-webdriver/cookies.rb +41 -0
- data/lib/watir-webdriver/element_collection.rb +13 -3
- data/lib/watir-webdriver/elements/button.rb +3 -1
- data/lib/watir-webdriver/elements/checkbox.rb +8 -6
- data/lib/watir-webdriver/elements/dlist.rb +4 -4
- data/lib/watir-webdriver/elements/element.rb +153 -28
- data/lib/watir-webdriver/elements/file_field.rb +6 -4
- data/lib/watir-webdriver/elements/generated.rb +12 -8
- data/lib/watir-webdriver/elements/image.rb +10 -5
- data/lib/watir-webdriver/elements/input.rb +6 -0
- data/lib/watir-webdriver/elements/option.rb +28 -2
- data/lib/watir-webdriver/elements/radio.rb +5 -1
- data/lib/watir-webdriver/elements/select.rb +11 -9
- data/lib/watir-webdriver/elements/table.rb +8 -1
- data/lib/watir-webdriver/elements/table_cell.rb +3 -3
- data/lib/watir-webdriver/elements/table_row.rb +0 -1
- data/lib/watir-webdriver/elements/table_section.rb +8 -2
- data/lib/watir-webdriver/elements/text_area.rb +2 -2
- data/lib/watir-webdriver/elements/text_field.rb +2 -2
- data/lib/watir-webdriver/extensions/alerts.rb +3 -3
- data/lib/watir-webdriver/extensions/nokogiri.rb +2 -2
- data/lib/watir-webdriver/extensions/select_text.rb +2 -2
- data/lib/watir-webdriver/has_window.rb +23 -1
- data/lib/watir-webdriver/html.rb +2 -0
- data/lib/watir-webdriver/html/visitor.rb +2 -2
- data/lib/watir-webdriver/locators/element_locator.rb +8 -0
- data/lib/watir-webdriver/locators/text_field_locator.rb +1 -1
- data/lib/watir-webdriver/row_container.rb +11 -3
- data/lib/watir-webdriver/screenshot.rb +11 -0
- data/lib/watir-webdriver/user_editable.rb +10 -4
- data/lib/watir-webdriver/version.rb +2 -2
- data/lib/watir-webdriver/wait.rb +32 -11
- data/lib/watir-webdriver/window.rb +104 -1
- data/lib/watir-webdriver/xpath_support.rb +4 -0
- data/lib/yard/handlers/watir.rb +1 -1
- data/spec/element_locator_spec.rb +14 -1
- data/spec/html/clicks.html +1 -1
- data/spec/implementation.rb +29 -6
- data/spec/wait_spec.rb +2 -2
- data/support/travis.sh +5 -3
- data/support/version_differ.rb +59 -0
- data/watir-webdriver.gemspec +4 -3
- metadata +146 -149
- data/spec/alert_spec.rb +0 -91
- data/spec/html/alerts.html +0 -12
- data/spec/screenshot_spec.rb +0 -25
- data/support/html5.html +0 -102577
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Watir
|
3
3
|
class FileField < Input
|
4
|
+
|
4
5
|
#
|
5
6
|
# Set the file field to the given path
|
6
7
|
#
|
7
8
|
# @param [String] a path
|
8
|
-
#
|
9
9
|
# @raise [Errno::ENOENT] if the file doesn't exist
|
10
10
|
#
|
11
11
|
|
@@ -15,16 +15,18 @@ module Watir
|
|
15
15
|
end
|
16
16
|
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# Sets the file field to the given path
|
19
19
|
#
|
20
|
-
# @param [String]
|
20
|
+
# @param [String] path
|
21
21
|
#
|
22
|
+
|
22
23
|
def value=(path)
|
23
24
|
assert_exists
|
24
25
|
path = path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
|
25
26
|
@element.send_keys path
|
26
27
|
end
|
27
|
-
|
28
|
+
|
29
|
+
end # FileField
|
28
30
|
|
29
31
|
module Container
|
30
32
|
def file_field(*args)
|
@@ -62,13 +62,17 @@ module Watir
|
|
62
62
|
|
63
63
|
|
64
64
|
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
65
69
|
|
66
70
|
|
67
71
|
|
68
72
|
|
69
73
|
|
70
74
|
class HTMLElement < Element
|
71
|
-
attributes(:string => [:access_key, :access_key_label, :
|
75
|
+
attributes(:string => [:access_key, :access_key_label, :command_icon, :command_label, :command_type, :content_editable, :dir, :item_id, :item_value, :lang, :title], :bool => [:command_checked, :command_disabled, :command_hidden, :draggable, :hidden, :content_editable, :item_scope, :spellcheck, :translate], :html_element => [:context_menu], :string_map => [:dataset], :token_list => [:dropzone, :item_prop, :item_ref, :item_type], :function => [:onabort, :onblur, :oncancel, :oncanplay, :oncanplaythrough, :onchange, :onclick, :onclose, :oncontextmenu, :oncuechange, :ondblclick, :ondrag, :ondragend, :ondragenter, :ondragleave, :ondragover, :ondragstart, :ondrop, :ondurationchange, :onemptied, :onended, :onerror, :onfocus, :oninput, :oninvalid, :onkeydown, :onkeypress, :onkeyup, :onload, :onloadeddata, :onloadedmetadata, :onloadstart, :onmousedown, :onmousemove, :onmouseout, :onmouseover, :onmouseup, :onmousewheel, :onpause, :onplay, :onplaying, :onprogress, :onratechange, :onreset, :onscroll, :onseeked, :onseeking, :onselect, :onshow, :onstalled, :onsubmit, :onsuspend, :ontimeupdate, :onvolumechange, :onwaiting], :properties_collection => [:properties], :style => [:style], :int => [:tab_index])
|
72
76
|
end
|
73
77
|
class HTMLElementCollection < ElementCollection
|
74
78
|
def element_class
|
@@ -200,7 +204,7 @@ module Watir
|
|
200
204
|
end
|
201
205
|
end
|
202
206
|
class TextArea < HTMLElement
|
203
|
-
attributes(:
|
207
|
+
attributes(:string => [:autocomplete, :default_value, :dir_name, :input_mode, :name, :placeholder, :selection_direction, :type, :validation_message, :validity, :value, :wrap], :bool => [:autofocus, :disabled, :read_only, :required, :will_validate], :int => [:cols, :max_length, :rows, :selection_end, :selection_start, :text_length], :html_element => [:form], :list => [:labels])
|
204
208
|
end
|
205
209
|
class TextAreaCollection < ElementCollection
|
206
210
|
def element_class
|
@@ -248,7 +252,7 @@ module Watir
|
|
248
252
|
end
|
249
253
|
end
|
250
254
|
class Input < HTMLElement
|
251
|
-
attributes(:string => [:accept, :alt, :autocomplete, :default_value, :dir_name, :form_action, :form_enctype, :form_method, :form_target, :max, :min, :name, :pattern, :placeholder, :selection_direction, :src, :step, :type, :validation_message, :validity, :value], :bool => [:autofocus, :checked, :default_checked, :disabled, :form_no_validate, :indeterminate, :multiple, :read_only, :required, :will_validate], :list => [:files, :labels], :html_element => [:form, :list], :int => [:height, :max_length, :selection_end, :selection_start, :size, :width], :date => [:value_as_date], :float => [:value_as_number])
|
255
|
+
attributes(:string => [:accept, :alt, :autocomplete, :default_value, :dir_name, :form_action, :form_enctype, :form_method, :form_target, :input_mode, :max, :min, :name, :pattern, :placeholder, :selection_direction, :src, :step, :type, :validation_message, :validity, :value], :bool => [:autofocus, :checked, :default_checked, :disabled, :form_no_validate, :indeterminate, :multiple, :read_only, :required, :will_validate], :list => [:files, :labels], :html_element => [:form, :list], :int => [:height, :max_length, :selection_end, :selection_start, :size, :width], :date => [:value_as_date], :float => [:value_as_number])
|
252
256
|
end
|
253
257
|
class InputCollection < ElementCollection
|
254
258
|
def element_class
|
@@ -308,7 +312,7 @@ module Watir
|
|
308
312
|
end
|
309
313
|
# do nothing
|
310
314
|
class TableHeaderCell < TableCell
|
311
|
-
attributes(:string => [:scope])
|
315
|
+
attributes(:string => [:abbr, :scope])
|
312
316
|
end
|
313
317
|
class TableHeaderCellCollection < ElementCollection
|
314
318
|
def element_class
|
@@ -372,7 +376,7 @@ module Watir
|
|
372
376
|
end
|
373
377
|
# do nothing
|
374
378
|
class Table < HTMLElement
|
375
|
-
attributes(:
|
379
|
+
attributes(:html_element => [:caption, :t_foot, :t_head], :html_collection => [:rows, :t_bodies])
|
376
380
|
end
|
377
381
|
class TableCollection < ElementCollection
|
378
382
|
def element_class
|
@@ -380,7 +384,7 @@ module Watir
|
|
380
384
|
end
|
381
385
|
end
|
382
386
|
class Table < HTMLElement
|
383
|
-
attributes(:string => [:align, :bg_color, :cell_padding, :cell_spacing, :frame, :rules, :summary, :width])
|
387
|
+
attributes(:string => [:align, :bg_color, :border, :cell_padding, :cell_spacing, :frame, :rules, :summary, :width])
|
384
388
|
end
|
385
389
|
# do nothing
|
386
390
|
class Area < HTMLElement
|
@@ -500,7 +504,7 @@ module Watir
|
|
500
504
|
end
|
501
505
|
# do nothing
|
502
506
|
class Image < HTMLElement
|
503
|
-
attributes(:string => [:alt, :cross_origin, :src, :use_map], :bool => [:complete, :map], :int => [:height, :natural_height, :natural_width, :width])
|
507
|
+
attributes(:string => [:alt, :cross_origin, :src, :srcset, :use_map], :bool => [:complete, :map], :int => [:height, :natural_height, :natural_width, :width])
|
504
508
|
end
|
505
509
|
class ImageCollection < ElementCollection
|
506
510
|
def element_class
|
@@ -1170,7 +1174,7 @@ module Watir
|
|
1170
1174
|
# @return [DataCollection]
|
1171
1175
|
#
|
1172
1176
|
|
1173
|
-
def
|
1177
|
+
def datas(*args)
|
1174
1178
|
DataCollection.new(self, extract_selector(args).merge(:tag_name => "data"))
|
1175
1179
|
end
|
1176
1180
|
|
@@ -2,6 +2,12 @@
|
|
2
2
|
module Watir
|
3
3
|
class Image < HTMLElement
|
4
4
|
|
5
|
+
#
|
6
|
+
# Returns true if image is loaded.
|
7
|
+
#
|
8
|
+
# @return [Boolean]
|
9
|
+
#
|
10
|
+
|
5
11
|
def loaded?
|
6
12
|
return false unless complete?
|
7
13
|
|
@@ -12,9 +18,9 @@ module Watir
|
|
12
18
|
end
|
13
19
|
|
14
20
|
#
|
15
|
-
#
|
21
|
+
# Returns the image's width in pixels.
|
16
22
|
#
|
17
|
-
# @return [
|
23
|
+
# @return [Fixnum] width
|
18
24
|
#
|
19
25
|
|
20
26
|
def width
|
@@ -23,9 +29,9 @@ module Watir
|
|
23
29
|
end
|
24
30
|
|
25
31
|
#
|
26
|
-
#
|
32
|
+
# Returns the image's height in pixels.
|
27
33
|
#
|
28
|
-
# @return [
|
34
|
+
# @return [Fixnum] width
|
29
35
|
#
|
30
36
|
|
31
37
|
def height
|
@@ -54,5 +60,4 @@ module Watir
|
|
54
60
|
alias_method :image, :img
|
55
61
|
alias_method :images, :imgs
|
56
62
|
end # Container
|
57
|
-
|
58
63
|
end # Watir
|
@@ -8,7 +8,10 @@ module Watir
|
|
8
8
|
class Option < HTMLElement
|
9
9
|
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# Selects this option.
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# browser.select(:id => "foo").options.first.select
|
12
15
|
#
|
13
16
|
|
14
17
|
def select
|
@@ -17,7 +20,10 @@ module Watir
|
|
17
20
|
end
|
18
21
|
|
19
22
|
#
|
20
|
-
#
|
23
|
+
# Toggles the selected state of this option.
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
# browser.select(:id => "foo").options.first.toggle
|
21
27
|
#
|
22
28
|
|
23
29
|
def toggle
|
@@ -25,6 +31,13 @@ module Watir
|
|
25
31
|
@element.click
|
26
32
|
end
|
27
33
|
|
34
|
+
#
|
35
|
+
# Clears (i.e. toggles selected state) option.
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# browser.select(:id => "foo").options.first.clear
|
39
|
+
#
|
40
|
+
|
28
41
|
def clear
|
29
42
|
@element.click if selected?
|
30
43
|
end
|
@@ -32,12 +45,25 @@ module Watir
|
|
32
45
|
#
|
33
46
|
# Is this option selected?
|
34
47
|
#
|
48
|
+
# @return [Boolean]
|
49
|
+
#
|
35
50
|
|
36
51
|
def selected?
|
37
52
|
assert_exists
|
38
53
|
@element.selected?
|
39
54
|
end
|
40
55
|
|
56
|
+
#
|
57
|
+
# Returns the text of option.
|
58
|
+
#
|
59
|
+
# Note that the text is either one of the following respectively:
|
60
|
+
# * label attribute
|
61
|
+
# * text attribute
|
62
|
+
# * inner element text
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
#
|
66
|
+
|
41
67
|
def text
|
42
68
|
assert_exists
|
43
69
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Watir
|
3
3
|
class Radio < Input
|
4
|
+
|
4
5
|
#
|
5
|
-
#
|
6
|
+
# Selects this radio button.
|
6
7
|
#
|
7
8
|
|
8
9
|
def set
|
@@ -15,11 +16,14 @@ module Watir
|
|
15
16
|
#
|
16
17
|
# Is this radio set?
|
17
18
|
#
|
19
|
+
# @return [Boolean]
|
20
|
+
#
|
18
21
|
|
19
22
|
def set?
|
20
23
|
assert_exists
|
21
24
|
@element.selected?
|
22
25
|
end
|
26
|
+
|
23
27
|
end # Radio
|
24
28
|
|
25
29
|
module Container
|
@@ -14,7 +14,7 @@ module Watir
|
|
14
14
|
end
|
15
15
|
|
16
16
|
#
|
17
|
-
#
|
17
|
+
# Clears all selected options.
|
18
18
|
#
|
19
19
|
|
20
20
|
def clear
|
@@ -28,7 +28,7 @@ module Watir
|
|
28
28
|
end
|
29
29
|
|
30
30
|
#
|
31
|
-
#
|
31
|
+
# Gets all the options in the select list
|
32
32
|
#
|
33
33
|
# @return [Watir::OptionCollection]
|
34
34
|
#
|
@@ -41,7 +41,7 @@ module Watir
|
|
41
41
|
#
|
42
42
|
# Returns true if the select list has one or more options where text or label matches the given value.
|
43
43
|
#
|
44
|
-
# @param [String, Regexp]
|
44
|
+
# @param [String, Regexp] str_or_rx
|
45
45
|
# @return [Boolean]
|
46
46
|
#
|
47
47
|
|
@@ -55,7 +55,7 @@ module Watir
|
|
55
55
|
# Select the option(s) whose text or label matches the given string.
|
56
56
|
# If this is a multi-select and several options match the value given, all will be selected.
|
57
57
|
#
|
58
|
-
# @param [String, Regexp]
|
58
|
+
# @param [String, Regexp] str_or_rx
|
59
59
|
# @raise [Watir::Exception::NoValueFoundException] if the value does not exist.
|
60
60
|
# @return [String] The text of the option selected. If multiple options match, returns the first match.
|
61
61
|
#
|
@@ -69,7 +69,7 @@ module Watir
|
|
69
69
|
#
|
70
70
|
# @see +select+
|
71
71
|
#
|
72
|
-
# @param [String, Regexp]
|
72
|
+
# @param [String, Regexp] str_or_rx
|
73
73
|
# @raise [Watir::Exception::NoValueFoundException] if the value does not exist.
|
74
74
|
# @return [String] The option selected. If multiple options match, returns the first match
|
75
75
|
#
|
@@ -79,10 +79,10 @@ module Watir
|
|
79
79
|
end
|
80
80
|
|
81
81
|
#
|
82
|
-
# Returns true if any of the selected options' text or label
|
82
|
+
# Returns true if any of the selected options' text or label matches the given value.
|
83
83
|
#
|
84
|
-
# @param [String, Regexp]
|
85
|
-
# @raise [Watir::Exception::UnknownObjectException] if the
|
84
|
+
# @param [String, Regexp] str_or_rx
|
85
|
+
# @raise [Watir::Exception::UnknownObjectException] if the options do not exist
|
86
86
|
# @return [Boolean]
|
87
87
|
#
|
88
88
|
|
@@ -111,7 +111,9 @@ module Watir
|
|
111
111
|
|
112
112
|
|
113
113
|
#
|
114
|
-
#
|
114
|
+
# Returns an array of currently selected options.
|
115
|
+
#
|
116
|
+
# @return [Array<Watir::Option>]
|
115
117
|
#
|
116
118
|
|
117
119
|
def selected_options
|
@@ -4,6 +4,12 @@ module Watir
|
|
4
4
|
class Table < HTMLElement
|
5
5
|
include RowContainer
|
6
6
|
|
7
|
+
#
|
8
|
+
# Represents table rows as hashes
|
9
|
+
#
|
10
|
+
# @return [Array<Hash>]
|
11
|
+
#
|
12
|
+
|
7
13
|
def hashes
|
8
14
|
all_rows = rows.to_a
|
9
15
|
header_row = all_rows.shift or raise Exception::Error, "no rows in table"
|
@@ -24,8 +30,9 @@ module Watir
|
|
24
30
|
end
|
25
31
|
|
26
32
|
#
|
27
|
-
#
|
33
|
+
# Returns row of this table with given index.
|
28
34
|
#
|
35
|
+
# @param [Fixnum] idx
|
29
36
|
# @return Watir::TableRow
|
30
37
|
#
|
31
38
|
|
@@ -11,7 +11,7 @@ module Watir
|
|
11
11
|
value = attribute_value :colspan
|
12
12
|
value ? Integer(value) : 1
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end # TableCell
|
15
15
|
|
16
16
|
class TableCellCollection < ElementCollection
|
17
17
|
attr_writer :locator_class
|
@@ -32,5 +32,5 @@ module Watir
|
|
32
32
|
elements
|
33
33
|
end
|
34
34
|
|
35
|
-
end
|
36
|
-
end
|
35
|
+
end # TableCellCollection
|
36
|
+
end # Watir
|
@@ -2,8 +2,14 @@ module Watir
|
|
2
2
|
class TableSection < HTMLElement
|
3
3
|
include RowContainer
|
4
4
|
|
5
|
+
#
|
6
|
+
# Returns table section row with given index.
|
7
|
+
#
|
8
|
+
# @param [Fixnum] idx
|
9
|
+
#
|
10
|
+
|
5
11
|
def [](idx)
|
6
12
|
row(:index => idx)
|
7
13
|
end
|
8
|
-
end
|
9
|
-
end
|
14
|
+
end # TableSection
|
15
|
+
end # Watir
|
@@ -18,7 +18,7 @@ module Watir
|
|
18
18
|
selector[:tag_name] = "input or textarea"
|
19
19
|
selector.inspect
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end # TextField
|
22
22
|
|
23
23
|
module Container
|
24
24
|
def text_field(*args)
|
@@ -41,4 +41,4 @@ module Watir
|
|
41
41
|
TextField
|
42
42
|
end
|
43
43
|
end # TextFieldCollection
|
44
|
-
end
|
44
|
+
end # Watir
|
@@ -22,7 +22,7 @@ module Watir
|
|
22
22
|
#
|
23
23
|
|
24
24
|
def alert(&blk)
|
25
|
-
warn 'AlertHelper is deprecated. Use the new Alert API instead (e.g. browser.alert.
|
25
|
+
warn 'AlertHelper is deprecated. Use the new Alert API instead (e.g. browser.alert.ok)'
|
26
26
|
execute_script "window.alert = function(msg) { window.__lastWatirAlert = msg; }"
|
27
27
|
yield
|
28
28
|
execute_script "return window.__lastWatirAlert"
|
@@ -39,7 +39,7 @@ module Watir
|
|
39
39
|
# end #=> "the confirm message"
|
40
40
|
|
41
41
|
def confirm(bool, &blk)
|
42
|
-
warn 'AlertHelper is deprecated. Use the new Alert API instead (e.g. browser.
|
42
|
+
warn 'AlertHelper is deprecated. Use the new Alert API instead (e.g. browser.alert.ok)'
|
43
43
|
execute_script "window.confirm = function(msg) { window.__lastWatirConfirm = msg; return #{!!bool} }"
|
44
44
|
yield
|
45
45
|
execute_script "return window.__lastWatirConfirm"
|
@@ -57,7 +57,7 @@ module Watir
|
|
57
57
|
#
|
58
58
|
|
59
59
|
def prompt(answer, &blk)
|
60
|
-
warn 'AlertHelper is deprecated. Use the new Alert API instead (e.g. browser.
|
60
|
+
warn 'AlertHelper is deprecated. Use the new Alert API instead (e.g. browser.alert.ok)'
|
61
61
|
execute_script "window.prompt = function(text, value) { window.__lastWatirPrompt = { message: text, default_value: value }; return #{MultiJson.encode answer}; }"
|
62
62
|
yield
|
63
63
|
result = execute_script "return window.__lastWatirPrompt"
|