watir 3.0.0.rc3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. data/Rakefile +5 -0
  2. data/lib/watir.rb +1 -0
  3. data/lib/watir/loader.rb +2 -0
  4. data/lib/watir/version.rb +3 -0
  5. data/watir.gemspec +18 -54
  6. metadata +32 -278
  7. data/CHANGES +0 -712
  8. data/LICENSE +0 -34
  9. data/README.rdoc +0 -101
  10. data/VERSION +0 -1
  11. data/bin/watir-console +0 -7
  12. data/lib/watir/IEDialog/Release/IEDialog.dll +0 -0
  13. data/lib/watir/close_all.rb +0 -31
  14. data/lib/watir/container.rb +0 -110
  15. data/lib/watir/contrib/enabled_popup.rb +0 -21
  16. data/lib/watir/contrib/ie-new-process.rb +0 -27
  17. data/lib/watir/contrib/page_checker.rb +0 -29
  18. data/lib/watir/cookies.rb +0 -80
  19. data/lib/watir/core.rb +0 -43
  20. data/lib/watir/dialogs/file_field.rb +0 -34
  21. data/lib/watir/dialogs/javascript.rb +0 -43
  22. data/lib/watir/drag_and_drop_helper.rb +0 -68
  23. data/lib/watir/element.rb +0 -441
  24. data/lib/watir/element_collection.rb +0 -109
  25. data/lib/watir/form.rb +0 -96
  26. data/lib/watir/frame.rb +0 -47
  27. data/lib/watir/ie-class.rb +0 -765
  28. data/lib/watir/ie-process.rb +0 -47
  29. data/lib/watir/ie.rb +0 -20
  30. data/lib/watir/image.rb +0 -111
  31. data/lib/watir/input_elements.rb +0 -480
  32. data/lib/watir/irb-history.rb +0 -31
  33. data/lib/watir/link.rb +0 -46
  34. data/lib/watir/locator.rb +0 -243
  35. data/lib/watir/logger.rb +0 -19
  36. data/lib/watir/modal_dialog.rb +0 -72
  37. data/lib/watir/module.rb +0 -12
  38. data/lib/watir/non_control_elements.rb +0 -114
  39. data/lib/watir/page-container.rb +0 -108
  40. data/lib/watir/process.rb +0 -20
  41. data/lib/watir/screen_capture.rb +0 -115
  42. data/lib/watir/supported_elements.rb +0 -172
  43. data/lib/watir/table.rb +0 -224
  44. data/lib/watir/win32.rb +0 -40
  45. data/lib/watir/win32ole.rb +0 -16
  46. data/lib/watir/win32ole/1.8.7/win32ole.so +0 -0
  47. data/lib/watir/win32ole/1.9.3/win32ole.so +0 -0
  48. data/lib/watir/window.rb +0 -68
  49. data/lib/watir/xpath_locator.rb +0 -52
  50. data/rakefile.rb +0 -54
  51. data/unittests/all_tests.rb +0 -10
  52. data/unittests/buttons_xpath_test.rb +0 -68
  53. data/unittests/checkbox_test.rb +0 -163
  54. data/unittests/checkbox_xpath_test.rb +0 -106
  55. data/unittests/click_no_wait_test.rb +0 -23
  56. data/unittests/close_all_test.rb +0 -17
  57. data/unittests/core_tests.rb +0 -17
  58. data/unittests/css_selector_test.rb +0 -44
  59. data/unittests/css_test.rb +0 -38
  60. data/unittests/dialog_test.rb +0 -64
  61. data/unittests/div2_xpath_test.rb +0 -21
  62. data/unittests/div_test.rb +0 -170
  63. data/unittests/div_xpath_test.rb +0 -95
  64. data/unittests/document_standards.rb +0 -63
  65. data/unittests/element_collection_indexes_test.rb +0 -57
  66. data/unittests/element_collections_test.rb +0 -100
  67. data/unittests/element_test.rb +0 -47
  68. data/unittests/errorchecker_test.rb +0 -31
  69. data/unittests/filefield_test.rb +0 -43
  70. data/unittests/filefield_xpath_test.rb +0 -35
  71. data/unittests/form_test.rb +0 -282
  72. data/unittests/form_xpath_test.rb +0 -254
  73. data/unittests/frame_test.rb +0 -165
  74. data/unittests/google_form_test.rb +0 -15
  75. data/unittests/html/JavascriptClick.html +0 -39
  76. data/unittests/html/blankpage.html +0 -11
  77. data/unittests/html/buttons1.html +0 -40
  78. data/unittests/html/checkboxes1.html +0 -89
  79. data/unittests/html/click_no_wait.html +0 -14
  80. data/unittests/html/complex_table.html +0 -35
  81. data/unittests/html/cssTest.html +0 -42
  82. data/unittests/html/depot_store.html +0 -59
  83. data/unittests/html/div.html +0 -92
  84. data/unittests/html/div_xml.html +0 -21
  85. data/unittests/html/fileupload.html +0 -44
  86. data/unittests/html/formTest1.html +0 -38
  87. data/unittests/html/forms2.html +0 -44
  88. data/unittests/html/forms3.html +0 -131
  89. data/unittests/html/forms4.html +0 -26
  90. data/unittests/html/frame_buttons.html +0 -4
  91. data/unittests/html/frame_links.html +0 -4
  92. data/unittests/html/frame_multi.html +0 -5
  93. data/unittests/html/google_india.html +0 -119
  94. data/unittests/html/ie7_document_standards.html +0 -9
  95. data/unittests/html/ie8_document_standards.html +0 -9
  96. data/unittests/html/ie9_document_standards.html +0 -9
  97. data/unittests/html/iframe.html +0 -3
  98. data/unittests/html/iframeTest.html +0 -17
  99. data/unittests/html/iframeTest1.html +0 -7
  100. data/unittests/html/iframeTest2.html +0 -5
  101. data/unittests/html/images/1.gif +0 -0
  102. data/unittests/html/images/2.GIF +0 -0
  103. data/unittests/html/images/3.GIF +0 -0
  104. data/unittests/html/images/button.jpg +0 -0
  105. data/unittests/html/images/circle.jpg +0 -0
  106. data/unittests/html/images/map.GIF +0 -0
  107. data/unittests/html/images/map2.gif +0 -0
  108. data/unittests/html/images/minus.GIF +0 -0
  109. data/unittests/html/images/originaltriangle.jpg +0 -0
  110. data/unittests/html/images/plus.gif +0 -0
  111. data/unittests/html/images/square.jpg +0 -0
  112. data/unittests/html/images/triangle.jpg +0 -0
  113. data/unittests/html/images1.html +0 -65
  114. data/unittests/html/javascriptevents.html +0 -33
  115. data/unittests/html/link_pass.html +0 -11
  116. data/unittests/html/links1.html +0 -37
  117. data/unittests/html/links2.html +0 -11
  118. data/unittests/html/links_multi.html +0 -12
  119. data/unittests/html/list_matters.html +0 -720
  120. data/unittests/html/lists.html +0 -18
  121. data/unittests/html/map_test.html +0 -30
  122. data/unittests/html/modal_dialog.html +0 -10
  123. data/unittests/html/modal_dialog_launcher.html +0 -12
  124. data/unittests/html/multiple_specifiers.html +0 -64
  125. data/unittests/html/nestedFrames.html +0 -6
  126. data/unittests/html/new_browser.html +0 -17
  127. data/unittests/html/pass.html +0 -13
  128. data/unittests/html/popups1.html +0 -59
  129. data/unittests/html/pre.html +0 -29
  130. data/unittests/html/quirks_document_standards.html +0 -8
  131. data/unittests/html/radioButtons1.html +0 -71
  132. data/unittests/html/select_tealeaf.html +0 -54
  133. data/unittests/html/selectboxes1.html +0 -52
  134. data/unittests/html/simple_table.html +0 -25
  135. data/unittests/html/simple_table_buttons.html +0 -104
  136. data/unittests/html/simple_table_columns.html +0 -75
  137. data/unittests/html/table1.html +0 -179
  138. data/unittests/html/tableCell_using_xpath.html +0 -19
  139. data/unittests/html/table_and_tablerow_to_a.html +0 -174
  140. data/unittests/html/textarea.html +0 -30
  141. data/unittests/html/textfields1.html +0 -100
  142. data/unittests/html/textsearch.html +0 -44
  143. data/unittests/html/wallofcheckboxes.html +0 -1003
  144. data/unittests/html/xpath_nbsp.html +0 -11
  145. data/unittests/html/zeroindex.html +0 -11
  146. data/unittests/ie_exists_test.rb +0 -16
  147. data/unittests/ie_mock.rb +0 -94
  148. data/unittests/ie_test.rb +0 -54
  149. data/unittests/images_test.rb +0 -156
  150. data/unittests/images_xpath_test.rb +0 -90
  151. data/unittests/index_specifier_test.rb +0 -31
  152. data/unittests/js_events_test.rb +0 -31
  153. data/unittests/links_multi_test.rb +0 -34
  154. data/unittests/links_test.rb +0 -131
  155. data/unittests/links_xpath_test.rb +0 -38
  156. data/unittests/lists_test.rb +0 -23
  157. data/unittests/map_test.rb +0 -98
  158. data/unittests/minmax_test.rb +0 -37
  159. data/unittests/navigate_test.rb +0 -38
  160. data/unittests/nbsp_xpath_test.rb +0 -16
  161. data/unittests/no_wait_test.rb +0 -28
  162. data/unittests/non_core_tests.rb +0 -12
  163. data/unittests/other/all_tests_concurrent.rb +0 -57
  164. data/unittests/other/navigate_exception_test.rb +0 -24
  165. data/unittests/other/rexml_unit_test.rb +0 -27
  166. data/unittests/other/screen_capture_test.rb +0 -53
  167. data/unittests/other/testcase_method_order_test.rb +0 -36
  168. data/unittests/other/testcase_verify_test.rb +0 -25
  169. data/unittests/other/wait_until_test.rb +0 -102
  170. data/unittests/pagecontainstext_test.rb +0 -69
  171. data/unittests/parent_child_test.rb +0 -27
  172. data/unittests/perf_test.rb +0 -20
  173. data/unittests/pre_test.rb +0 -49
  174. data/unittests/radios_test.rb +0 -181
  175. data/unittests/radios_xpath_test.rb +0 -100
  176. data/unittests/security_setting_test.rb +0 -24
  177. data/unittests/selectbox_test.rb +0 -144
  178. data/unittests/selectbox_xpath_test.rb +0 -102
  179. data/unittests/setup.rb +0 -70
  180. data/unittests/speed_settings_test.rb +0 -67
  181. data/unittests/table_cell_using_xpath_test.rb +0 -34
  182. data/unittests/table_test.rb +0 -296
  183. data/unittests/table_xpath_test.rb +0 -109
  184. data/unittests/test_tests.rb +0 -9
  185. data/unittests/textarea_test.rb +0 -92
  186. data/unittests/textarea_xpath_test.rb +0 -77
  187. data/unittests/textfield_for_ch_char_test.rb +0 -32
  188. data/unittests/textfields_test.rb +0 -184
  189. data/unittests/textfields_xpath_test.rb +0 -110
  190. data/unittests/version_test.rb +0 -15
  191. data/unittests/win32ole_so_test.rb +0 -35
  192. data/unittests/window_tests.rb +0 -10
  193. data/unittests/windows/attach_to_existing_window_test.rb +0 -52
  194. data/unittests/windows/attach_to_new_window_test.rb +0 -74
  195. data/unittests/windows/close_window_test.rb +0 -20
  196. data/unittests/windows/frame_links_test.rb +0 -23
  197. data/unittests/windows/ie-each_test.rb +0 -46
  198. data/unittests/windows/modal_dialog_test.rb +0 -95
  199. data/unittests/windows/new_process_test.rb +0 -24
  200. data/unittests/windows/new_test.rb +0 -58
  201. data/unittests/windows/open_close_test.rb +0 -19
  202. data/unittests/windows/send_keys_test.rb +0 -26
  203. data/unittests/xpath_tests.rb +0 -11
  204. data/watir-rdoc.rb +0 -7
@@ -1,108 +0,0 @@
1
- module Watir
2
- # A PageContainer contains an HTML Document. In other words, it is a
3
- # what JavaScript calls a Window.
4
- module PageContainer
5
- include Watir::Exception
6
-
7
- # This method checks the currently displayed page for http errors, 404, 500 etc
8
- # It gets called internally by the wait method, so a user does not need to call it explicitly
9
-
10
- def check_for_http_error
11
- # check for IE7
12
- n = self.document.invoke('parentWindow').navigator.appVersion
13
- m=/MSIE\s(.*?);/.match( n )
14
- if m and m[1] =='7.0'
15
- if m = /HTTP (\d\d\d.*)/.match( self.title )
16
- raise NavigationException, m[1]
17
- end
18
- else
19
- # assume its IE6
20
- url = self.document.location.href
21
- if /shdoclc.dll/.match(url)
22
- m = /id=IEText.*?>(.*?)</i.match(self.html)
23
- raise NavigationException, m[1] if m
24
- end
25
- end
26
- false
27
- end
28
-
29
- # The HTML Page
30
- def page
31
- document.documentelement
32
- end
33
-
34
- private :page
35
-
36
- # Execute the given JavaScript string
37
- def execute_script(source)
38
- document.parentWindow.eval(source.to_s)
39
- rescue WIN32OLERuntimeError, NoMethodError #if eval fails we need to use execScript(source.to_s) which does not return a value, hence the workaround
40
- escaped_src = source.to_s.gsub(/[\r\n']/) {|m| "\\#{m}"}
41
- wrapper = "_watir_helper_div_#{::Time.now.to_i + ::Time.now.usec}"
42
- cmd = "var e = document.createElement('DIV'); e.style.display='none'; e.id='#{wrapper}'; e.innerHTML = eval('#{escaped_src}'); document.body.appendChild(e);"
43
- document.parentWindow.execScript(cmd)
44
- document.getElementById(wrapper).innerHTML
45
- end
46
-
47
- # The HTML of the current page
48
- def html
49
- page.outerhtml
50
- end
51
-
52
- # The url of the page object.
53
- def url
54
- page.document.location.href
55
- end
56
-
57
- # The text of the current page
58
- def text
59
- page.innertext.strip
60
- end
61
-
62
- def set_container container
63
- @container = container
64
- @page_container = self
65
- end
66
-
67
- # This method is used to display the available html frames that Internet Explorer currently has loaded.
68
- # This method is usually only used for debugging test scripts.
69
- def show_frames
70
- if allFrames = document.frames
71
- count = allFrames.length
72
- puts "there are #{count} frames"
73
- for i in 0..count-1 do
74
- begin
75
- fname = allFrames.item(i).name.to_s
76
- puts "frame index: #{i + 1} name: #{fname}"
77
- rescue => e
78
- if e.to_s.match(/Access is denied/)
79
- puts "frame index: #{i + 1} Access Denied, see http://wiki.openqa.org/display/WTR/FAQ#access-denied"
80
- end
81
- end
82
- end
83
- else
84
- puts "no frames"
85
- end
86
- end
87
-
88
- # Search the current page for specified text or regexp.
89
- # Returns the index if the specified text was found.
90
- # Returns matchdata object if the specified regexp was found.
91
- #
92
- # *Deprecated*
93
- # Instead use
94
- # IE#text.include? target
95
- # or
96
- # IE#text.match target
97
- def contains_text(target)
98
- if target.kind_of? Regexp
99
- self.text.match(target)
100
- elsif target.kind_of? String
101
- self.text.index(target)
102
- else
103
- raise ArgumentError, "Argument #{target} should be a string or regexp."
104
- end
105
- end
106
-
107
- end # module
108
- end
data/lib/watir/process.rb DELETED
@@ -1,20 +0,0 @@
1
- module Watir
2
- module Process
3
-
4
- # Returns the number of windows processes running with the specified name.
5
- def self.count name
6
- mgmt = WIN32OLE.connect('winmgmts:\\\\.')
7
- processes = mgmt.InstancesOf('win32_process')
8
- processes.extend Enumerable
9
- processes.select{|x| x.name == name}.length
10
- end
11
-
12
- end
13
-
14
- class IE
15
- # Returns the number of IEXPLORE processes currently running.
16
- def self.process_count
17
- Watir::Process.count 'iexplore.exe'
18
- end
19
- end
20
- end
@@ -1,115 +0,0 @@
1
-
2
- require 'Win32API'
3
-
4
- module Watir
5
- module ScreenCapture
6
-
7
- KEYEVENTF_KEYUP = 0x2
8
- SW_HIDE = 0
9
- SW_SHOW = 5
10
- SW_SHOWNORMAL = 1
11
- VK_CONTROL = 0x11
12
- VK_F4 = 0x73
13
- VK_MENU = 0x12
14
- VK_RETURN = 0x0D
15
- VK_SHIFT = 0x10
16
- VK_SNAPSHOT = 0x2C
17
- VK_TAB = 0x09
18
- GMEM_MOVEABLE = 0x0002
19
- CF_TEXT = 1
20
-
21
- # this method saves the current window or whole screen as either a bitmap or a jpeg
22
- # It uses paint to save the file, so will barf if a duplicate filename is selected, or the path doesnt exist etc
23
- # * filename - string - the name of the file to save. If its not fully qualified the current directory is used
24
- # * active_window - boolean - if true, the whole screen is captured, if false, just the active window is captured
25
- # * save_as_bmp - boolean - if true saves the file as a bitmap, saves it as a jpeg otherwise
26
- def screen_capture(filename , active_window_only=false, save_as_bmp=false)
27
-
28
-
29
- keybd_event = Win32API.new("user32", "keybd_event", ['I','I','L','L'], 'V')
30
- vkKeyScan = Win32API.new("user32", "VkKeyScan", ['I'], 'I')
31
- winExec = Win32API.new("kernel32", "WinExec", ['P','L'], 'L')
32
- openClipboard = Win32API.new('user32', 'OpenClipboard', ['L'], 'I')
33
- setClipboardData = Win32API.new('user32', 'SetClipboardData', ['I', 'I'], 'I')
34
- closeClipboard = Win32API.new('user32', 'CloseClipboard', [], 'I')
35
- globalAlloc = Win32API.new('kernel32', 'GlobalAlloc', ['I', 'I'], 'I')
36
- globalLock = Win32API.new('kernel32', 'GlobalLock', ['I'], 'I')
37
- globalUnlock = Win32API.new('kernel32', 'GlobalUnlock', ['I'], 'I')
38
- memcpy = Win32API.new('msvcrt', 'memcpy', ['I', 'P', 'I'], 'I')
39
-
40
-
41
- filename = Dir.getwd.tr('/','\\') + '\\' + filename unless filename.index('\\')
42
-
43
- if active_window_only ==false
44
- keybd_event.Call(VK_SNAPSHOT,0,0,0) # Print Screen
45
- else
46
- keybd_event.Call(VK_SNAPSHOT,1,0,0) # Alt+Print Screen
47
- end
48
-
49
- winExec.Call('mspaint.exe', SW_SHOW)
50
- sleep(1)
51
-
52
- # Ctrl + V : Paste
53
- keybd_event.Call(VK_CONTROL, 1, 0, 0)
54
- keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0)
55
- keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0)
56
- keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0)
57
-
58
-
59
- # Alt F + A : Save As
60
- keybd_event.Call(VK_MENU, 1, 0, 0)
61
- keybd_event.Call(vkKeyScan.Call(?F), 1, 0, 0)
62
- keybd_event.Call(vkKeyScan.Call(?F), 1, KEYEVENTF_KEYUP, 0)
63
- keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0)
64
- keybd_event.Call(vkKeyScan.Call(?A), 1, 0, 0)
65
- keybd_event.Call(vkKeyScan.Call(?A), 1, KEYEVENTF_KEYUP, 0)
66
- sleep(1)
67
-
68
- # copy filename to clipboard
69
- hmem = globalAlloc.Call(GMEM_MOVEABLE, filename.length+1)
70
- mem = globalLock.Call(hmem)
71
- memcpy.Call(mem, filename, filename.length+1)
72
- globalUnlock.Call(hmem)
73
- openClipboard.Call(0)
74
- setClipboardData.Call(CF_TEXT, hmem)
75
- closeClipboard.Call
76
- sleep(1)
77
-
78
- # Ctrl + V : Paste
79
- keybd_event.Call(VK_CONTROL, 1, 0, 0)
80
- keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0)
81
- keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0)
82
- keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0)
83
-
84
- if save_as_bmp == false
85
- # goto the combo box
86
- keybd_event.Call(VK_TAB, 1, 0, 0)
87
- keybd_event.Call(VK_TAB, 1, KEYEVENTF_KEYUP, 0)
88
- sleep(0.5)
89
-
90
- # select the first entry with J
91
- keybd_event.Call(vkKeyScan.Call(?J), 1, 0, 0)
92
- keybd_event.Call(vkKeyScan.Call(?J), 1, KEYEVENTF_KEYUP, 0)
93
- sleep(0.5)
94
- end
95
-
96
- # Enter key
97
- keybd_event.Call(VK_RETURN, 1, 0, 0)
98
- keybd_event.Call(VK_RETURN, 1, KEYEVENTF_KEYUP, 0)
99
- sleep(1)
100
-
101
- # Alt + F4 : Exit
102
- keybd_event.Call(VK_MENU, 1, 0, 0)
103
- keybd_event.Call(VK_F4, 1, 0, 0)
104
- keybd_event.Call(VK_F4, 1, KEYEVENTF_KEYUP, 0)
105
- keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0)
106
- sleep(1)
107
-
108
- end
109
- end
110
-
111
- end
112
-
113
-
114
- #screenCapture( "f.bmp", false , true)
115
-
@@ -1,172 +0,0 @@
1
- module Watir
2
- module Container
3
-
4
- class << self
5
- def support_element method_name, args={}
6
- klass = args[:class] || method_name.to_s.capitalize
7
- super_class = args[:super_class] || "Element"
8
-
9
- unless Watir.const_defined? klass
10
- Watir.class_eval %Q[class #{klass} < #{super_class}; end]
11
- end
12
-
13
- unless Watir.const_defined? "#{klass}Collection"
14
- Watir.class_eval %Q[class #{klass}Collection < #{args[:super_collection] || super_class}Collection; end]
15
- end
16
-
17
- tag_name = args[:tag_name] || method_name
18
-
19
- Watir::Container.module_eval %Q[
20
- def #{method_name}(how={}, what=nil)
21
- #{klass}.new(self, format_specifiers(#{tag_name.inspect}, how, what))
22
- end
23
-
24
- def #{args.delete(:plural) || method_name.to_s + "s"}(how={}, what=nil)
25
- specifiers = format_specifiers(#{tag_name.inspect}, how, what)
26
- #{klass}Collection.new(self, specifiers)
27
- end
28
- ]
29
- end
30
-
31
- private :support_element
32
- end
33
-
34
- def format_specifiers(tag_name, how, what)
35
- defaults = {:tag_name => [tag_name].flatten.map(&:to_s)}
36
- formatted_specifiers = defaults.merge(what ? {how => what} : how)
37
- if (formatted_specifiers[:css] || formatted_specifiers[:xpath]) && formatted_specifiers.size > 2
38
- raise ArgumentError, ":xpath and :css specifiers should be the only one when used in #{formatted_specifiers.inspect}"
39
- end
40
- formatted_specifiers
41
- end
42
-
43
- private :format_specifiers
44
-
45
- support_element :a, :class => :Link
46
- alias_method :link, :a
47
- alias_method :links, :as
48
- support_element :abbr
49
- support_element :address, :plural => :addresses
50
- support_element :area
51
- support_element :article
52
- support_element :aside
53
- support_element :audio
54
- support_element :b
55
- support_element :base
56
- support_element :bdi
57
- support_element :bdo
58
- support_element :blockquote
59
- support_element :body
60
- support_element :br
61
- support_element :button, :tag_name => [:button, :submit, :image, :reset], :super_class => :InputElement
62
- support_element :canvas, :plural => :canvases
63
- support_element :caption
64
- support_element :checkbox, :plural => :checkboxes, :class => :CheckBox, :super_class => :InputElement
65
- support_element :cite
66
- support_element :code
67
- support_element :col
68
- support_element :colgroup
69
- support_element :command
70
- support_element :data
71
- support_element :datalist
72
- support_element :dd
73
- support_element :del
74
- support_element :details, :plural => :detailses
75
- support_element :dfn
76
- support_element :div
77
- support_element :dl
78
- support_element :dt
79
- support_element :element, :tag_name => "*", :class => :HTMLElement
80
- support_element :em
81
- support_element :embed
82
- support_element :fieldset, :class => :FieldSet
83
- alias_method :field_set, :fieldset
84
- alias_method :field_sets, :fieldsets
85
- support_element :figcaption
86
- support_element :figure
87
- support_element :file_field, :tag_name => :file, :class => :FileField, :super_collection => :InputElement
88
- support_element :font
89
- support_element :footer
90
- support_element :form
91
- support_element :frame, :tag_name => [:frame, :iframe]
92
- alias_method :iframe, :frame
93
- alias_method :iframes, :frames
94
- support_element :frameset
95
- support_element :h1
96
- support_element :h2
97
- support_element :h3
98
- support_element :h4
99
- support_element :h5
100
- support_element :h6
101
- support_element :head
102
- support_element :header
103
- support_element :hgroup
104
- support_element :hidden, :super_class => :TextField, :super_collection => :InputElement
105
- support_element :hr
106
- # html and htmls?!
107
- support_element :i
108
- support_element :img, :class => :Image
109
- alias_method :image, :img
110
- alias_method :images, :imgs
111
- support_element :input, :super_class => :InputElement
112
- support_element :ins, :plural => :inses
113
- support_element :kbd
114
- support_element :keygen
115
- support_element :label
116
- support_element :legend
117
- support_element :li
118
- support_element :map
119
- support_element :mark
120
- support_element :menu
121
- support_element :meta
122
- support_element :meter
123
- support_element :nav
124
- support_element :noscript
125
- support_element :object
126
- support_element :ol
127
- support_element :optgroup
128
- support_element :option
129
- support_element :output
130
- support_element :p
131
- support_element :param
132
- support_element :pre
133
- support_element :progress, :plural => :progresses
134
- support_element :q
135
- support_element :radio, :super_class => :InputElement
136
- support_element :rp
137
- support_element :rt
138
- support_element :ruby, :plural => :rubies
139
- support_element :s
140
- support_element :samp
141
- support_element :script
142
- support_element :section
143
- support_element :select, :class => :SelectList, :super_class => :InputElement
144
- alias_method :select_list, :select
145
- alias_method :select_lists, :selects
146
- support_element :small
147
- support_element :source
148
- support_element :span
149
- support_element :strong
150
- support_element :style
151
- support_element :sub
152
- support_element :summary, :plural => :summaries
153
- support_element :sup
154
- support_element :table
155
- support_element :tbody, :class => :TableSection
156
- support_element :td, :tag_name => [:th, :td], :class => :TableCell
157
- support_element :text_field, :tag_name => [:text, :password, :textarea], :class => :TextField, :super_class => :InputElement
158
- support_element :textarea, :class => :TextArea, :super_class => :TextField, :super_collection => :InputElement
159
- support_element :tfoot, :class => :TableSection
160
- support_element :th
161
- support_element :thead, :class => :TableSection
162
- support_element :time
163
- support_element :title
164
- support_element :tr, :class => :TableRow
165
- support_element :track
166
- support_element :u
167
- support_element :ul
168
- support_element :var
169
- support_element :video
170
- support_element :wbr
171
- end
172
- end
data/lib/watir/table.rb DELETED
@@ -1,224 +0,0 @@
1
- module Watir
2
-
3
- module TableContainer
4
- # Returns a row in the table
5
- # * index - the index of the row
6
- def [](index)
7
- assert_exists
8
- TableRow.new(self, :ole_object => @o.rows.item(index))
9
- end
10
-
11
- def strings
12
- assert_exists
13
- rows_memo = []
14
- @o.rows.each do |row|
15
- cells_memo = []
16
- row.cells.each do |cell|
17
- cells_memo << TableCell.new(self, :ole_object => cell).text.gsub("\r\n","")
18
- end
19
- rows_memo << cells_memo
20
- end
21
- rows_memo
22
- end
23
- end
24
-
25
- module TableElementsContainer
26
- def table_elements(klass, tags, how, what, ole_collection)
27
- specifiers = format_specifiers(tags, how, what)
28
- klass.new(self, specifiers, ole_collection)
29
- end
30
-
31
- private :table_elements
32
- end
33
-
34
- module TableCellsContainer
35
- include TableElementsContainer
36
-
37
- def cells(how={}, what=nil)
38
- assert_exists
39
- table_elements(TableCellCollection, [:th, :td], how, what, @o.cells)
40
- end
41
-
42
- def cell(how={}, what=nil)
43
- specifiers = format_specifiers([:th, :td], how, what)
44
- index = specifiers.delete(:index) || 0
45
- cells(specifiers)[index]
46
- end
47
- end
48
-
49
- module TableRowsContainer
50
- include TableElementsContainer
51
-
52
- def rows(how={}, what=nil)
53
- assert_exists
54
- table_elements(TableRowCollection, [:tr], how, what, @o.rows)
55
- end
56
-
57
- def row(how={}, what=nil)
58
- specifiers = format_specifiers([:tr], how, what)
59
- index = specifiers.delete(:index) || 0
60
- rows(specifiers)[index]
61
- end
62
- end
63
-
64
- # This class is used for dealing with tables.
65
- # Normally a user would not need to create this object as it is returned by the Watir::Container#table method
66
- #
67
- # many of the methods available to this object are inherited from the Element class
68
- #
69
- class Table < Element
70
- include TableContainer
71
- include TableRowsContainer
72
- include TableCellsContainer
73
-
74
- attr_ole :rules
75
-
76
- # override the highlight method, as if the tables rows are set to have a background color,
77
- # this will override the table background color, and the normal flash method won't work
78
- def highlight(set_or_clear)
79
- if set_or_clear == :set
80
- begin
81
- @original_border = @o.border.to_i
82
- if @o.border.to_i==1
83
- @o.border = 2
84
- else
85
- @o.border = 1
86
- end
87
- rescue
88
- @original_border = nil
89
- end
90
- else
91
- begin
92
- @o.border= @original_border unless @original_border == nil
93
- @original_border = nil
94
- rescue
95
- # we could be here for a number of reasons...
96
- ensure
97
- @original_border = nil
98
- end
99
- end
100
- super
101
- end
102
-
103
- # this method is used to populate the properties in the to_s method
104
- def table_string_creator
105
- n = []
106
- n << "rows:".ljust(TO_S_SIZE) + self.row_count.to_s
107
- n << "cols:".ljust(TO_S_SIZE) + self.column_count.to_s
108
- return n
109
- end
110
- private :table_string_creator
111
-
112
- # returns the properties of the object in a string
113
- # raises an ObjectNotFound exception if the object cannot be found
114
- def to_s
115
- assert_exists
116
- r = string_creator
117
- r += table_string_creator
118
- return r.join("\n")
119
- end
120
-
121
- # Returns the number of rows inside the table, including rows in nested tables.
122
- def row_count
123
- assert_exists
124
- rows.length
125
- end
126
-
127
- # This method returns the number of columns in a row of the table.
128
- # Raises an UnknownObjectException if the table doesn't exist.
129
- # * index - the index of the row
130
- def column_count(index=0)
131
- assert_exists
132
- rows[index].cells.length
133
- end
134
-
135
- # Returns an array containing all the text values in the specified column
136
- # Raises an UnknownCellException if the specified column does not exist in every
137
- # Raises an UnknownObjectException if the table doesn't exist.
138
- # row of the table
139
- # * columnnumber - column index to extract values from
140
- def column_values(columnnumber)
141
- return (0..row_count - 1).collect {|i| self[i][columnnumber].text}
142
- end
143
-
144
- # Returns an array containing all the text values in the specified row
145
- # Raises an UnknownObjectException if the table doesn't exist.
146
- # * rownumber - row index to extract values from
147
- def row_values(rownumber)
148
- return (0..column_count(rownumber) - 1).collect {|i| self[rownumber][i].text}
149
- end
150
-
151
- def hashes
152
- assert_exists
153
-
154
- headers = []
155
- @o.rows.item(0).cells.each do |cell|
156
- headers << TableCell.new(self, :ole_object => cell).text
157
- end
158
-
159
- rows_memo = []
160
- i = 0
161
- @o.rows.each do |row|
162
- next if row.uniqueID == @o.rows.item(0).uniqueID
163
-
164
- cells_memo = {}
165
- cells = row.cells
166
- raise "row at index #{i} has #{cells.length} cells, expected #{headers.length}" if cells.length < headers.length
167
-
168
- j = 0
169
- cells.each do |cell|
170
- cells_memo[headers[j]] = TableCell.new(self, :ole_object => cell).text
171
- j += 1
172
- end
173
-
174
- rows_memo << cells_memo
175
- i += 1
176
- end
177
- rows_memo
178
- end
179
- end
180
-
181
- class TableSection < Element
182
- include TableContainer
183
- include TableRowsContainer
184
- include TableCellsContainer
185
- end
186
-
187
- class TableRow < Element
188
- include TableCellsContainer
189
-
190
- # this method iterates through each of the cells in the row. Yields a TableCell object
191
- def each
192
- locate
193
- cells.each {|cell| yield cell}
194
- end
195
-
196
- # Returns an element from the row as a TableCell object
197
- def [](index)
198
- assert_exists
199
- if cells.length <= index
200
- raise UnknownCellException, "Unable to locate a cell at index #{index}"
201
- end
202
- return cells[index]
203
- end
204
-
205
- def column_count
206
- assert_exists
207
- cells.length
208
- end
209
-
210
- end
211
-
212
- # this class is a table cell - when called via the Table object
213
- class TableCell < Element
214
- attr_ole :headers
215
-
216
- alias_method :to_s, :text
217
-
218
- def colspan
219
- locate
220
- @o.colSpan
221
- end
222
- end
223
-
224
- end