watir-classic 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. data/.gitignore +7 -0
  2. data/.gitmodules +3 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +5 -0
  5. data/CHANGES +20 -10
  6. data/CONTRIBUTORS.txt +55 -0
  7. data/Gemfile +3 -0
  8. data/Gemfile.lock +78 -0
  9. data/README.rdoc +8 -14
  10. data/Rakefile +32 -0
  11. data/VERSION +1 -1
  12. data/lib/watir-classic.rb +0 -1
  13. data/lib/watir-classic/IEDialog/IEDialog.cpp +225 -0
  14. data/lib/watir-classic/IEDialog/IEDialog.h +15 -0
  15. data/lib/watir-classic/IEDialog/IEDialog.vcproj +159 -0
  16. data/lib/watir-classic/IEDialog/ReadMe.txt +40 -0
  17. data/lib/watir-classic/IEDialog/stdafx.cpp +8 -0
  18. data/lib/watir-classic/IEDialog/stdafx.h +21 -0
  19. data/lib/watir-classic/browser.rb +1 -1
  20. data/lib/watir-classic/container.rb +4 -33
  21. data/lib/watir-classic/core.rb +1 -3
  22. data/lib/watir-classic/dialogs/alert.rb +46 -0
  23. data/lib/watir-classic/dialogs/file_field.rb +1 -0
  24. data/lib/watir-classic/drag_and_drop_helper.rb +18 -6
  25. data/lib/watir-classic/element.rb +0 -2
  26. data/lib/watir-classic/ext/json2.js +487 -0
  27. data/lib/watir-classic/ie-class.rb +10 -164
  28. data/lib/watir-classic/ie.rb +2 -0
  29. data/lib/watir-classic/input_elements.rb +1 -1
  30. data/lib/watir-classic/modal_dialog.rb +1 -7
  31. data/lib/watir-classic/module.rb +1 -10
  32. data/lib/watir-classic/non_control_elements.rb +11 -0
  33. data/lib/watir-classic/page-container.rb +22 -24
  34. data/lib/watir-classic/screenshot.rb +33 -0
  35. data/lib/watir-classic/win32ole/1.8.7/win32ole.patch +56 -0
  36. data/lib/watir-classic/win32ole/1.9.3/win32ole.patch +63 -0
  37. data/lib/watir-classic/win32ole/build_notes.txt +18 -0
  38. data/lib/watir-classic/win32ole/history.txt +88 -0
  39. data/spec/browser_spec.rb +34 -0
  40. data/spec/implementation.rb +18 -0
  41. data/watir-classic.gemspec +40 -0
  42. data/watir.gif +0 -0
  43. metadata +159 -192
  44. data/bin/watir-console +0 -5
  45. data/lib/watir-classic/assertions.rb +0 -44
  46. data/lib/watir-classic/dialogs/javascript.rb +0 -43
  47. data/lib/watir-classic/irb-history.rb +0 -31
  48. data/lib/watir-classic/logger.rb +0 -19
  49. data/lib/watir-classic/screen_capture.rb +0 -115
  50. data/lib/watir-classic/testcase.rb +0 -97
  51. data/lib/watir-classic/waiter.rb +0 -98
  52. data/rakefile.rb +0 -54
  53. data/unittests/all_tests.rb +0 -10
  54. data/unittests/buttons_xpath_test.rb +0 -68
  55. data/unittests/checkbox_test.rb +0 -163
  56. data/unittests/checkbox_xpath_test.rb +0 -106
  57. data/unittests/click_no_wait_test.rb +0 -23
  58. data/unittests/close_all_test.rb +0 -17
  59. data/unittests/core_tests.rb +0 -17
  60. data/unittests/css_selector_test.rb +0 -44
  61. data/unittests/css_test.rb +0 -38
  62. data/unittests/dialog_test.rb +0 -64
  63. data/unittests/div2_xpath_test.rb +0 -21
  64. data/unittests/div_test.rb +0 -170
  65. data/unittests/div_xpath_test.rb +0 -95
  66. data/unittests/document_standards.rb +0 -63
  67. data/unittests/element_collection_indexes_test.rb +0 -57
  68. data/unittests/element_collections_test.rb +0 -100
  69. data/unittests/element_test.rb +0 -47
  70. data/unittests/errorchecker_test.rb +0 -31
  71. data/unittests/filefield_test.rb +0 -43
  72. data/unittests/filefield_xpath_test.rb +0 -35
  73. data/unittests/form_test.rb +0 -282
  74. data/unittests/form_xpath_test.rb +0 -254
  75. data/unittests/frame_test.rb +0 -165
  76. data/unittests/google_form_test.rb +0 -15
  77. data/unittests/html/JavascriptClick.html +0 -39
  78. data/unittests/html/blankpage.html +0 -11
  79. data/unittests/html/buttons1.html +0 -40
  80. data/unittests/html/checkboxes1.html +0 -89
  81. data/unittests/html/click_no_wait.html +0 -14
  82. data/unittests/html/complex_table.html +0 -35
  83. data/unittests/html/cssTest.html +0 -42
  84. data/unittests/html/depot_store.html +0 -59
  85. data/unittests/html/div.html +0 -92
  86. data/unittests/html/div_xml.html +0 -21
  87. data/unittests/html/fileupload.html +0 -44
  88. data/unittests/html/formTest1.html +0 -38
  89. data/unittests/html/forms2.html +0 -44
  90. data/unittests/html/forms3.html +0 -131
  91. data/unittests/html/forms4.html +0 -26
  92. data/unittests/html/frame_buttons.html +0 -4
  93. data/unittests/html/frame_links.html +0 -4
  94. data/unittests/html/frame_multi.html +0 -5
  95. data/unittests/html/google_india.html +0 -119
  96. data/unittests/html/ie7_document_standards.html +0 -9
  97. data/unittests/html/ie8_document_standards.html +0 -9
  98. data/unittests/html/ie9_document_standards.html +0 -9
  99. data/unittests/html/iframe.html +0 -3
  100. data/unittests/html/iframeTest.html +0 -17
  101. data/unittests/html/iframeTest1.html +0 -7
  102. data/unittests/html/iframeTest2.html +0 -5
  103. data/unittests/html/images/1.gif +0 -0
  104. data/unittests/html/images/2.GIF +0 -0
  105. data/unittests/html/images/3.GIF +0 -0
  106. data/unittests/html/images/button.jpg +0 -0
  107. data/unittests/html/images/circle.jpg +0 -0
  108. data/unittests/html/images/map.GIF +0 -0
  109. data/unittests/html/images/map2.gif +0 -0
  110. data/unittests/html/images/minus.GIF +0 -0
  111. data/unittests/html/images/originaltriangle.jpg +0 -0
  112. data/unittests/html/images/plus.gif +0 -0
  113. data/unittests/html/images/square.jpg +0 -0
  114. data/unittests/html/images/triangle.jpg +0 -0
  115. data/unittests/html/images1.html +0 -65
  116. data/unittests/html/javascriptevents.html +0 -33
  117. data/unittests/html/link_pass.html +0 -11
  118. data/unittests/html/links1.html +0 -37
  119. data/unittests/html/links2.html +0 -11
  120. data/unittests/html/links_multi.html +0 -12
  121. data/unittests/html/list_matters.html +0 -720
  122. data/unittests/html/lists.html +0 -18
  123. data/unittests/html/map_test.html +0 -30
  124. data/unittests/html/modal_dialog.html +0 -10
  125. data/unittests/html/modal_dialog_launcher.html +0 -12
  126. data/unittests/html/multiple_specifiers.html +0 -64
  127. data/unittests/html/nestedFrames.html +0 -6
  128. data/unittests/html/new_browser.html +0 -17
  129. data/unittests/html/pass.html +0 -13
  130. data/unittests/html/popups1.html +0 -59
  131. data/unittests/html/pre.html +0 -29
  132. data/unittests/html/quirks_document_standards.html +0 -8
  133. data/unittests/html/radioButtons1.html +0 -71
  134. data/unittests/html/select_tealeaf.html +0 -54
  135. data/unittests/html/selectboxes1.html +0 -52
  136. data/unittests/html/simple_table.html +0 -25
  137. data/unittests/html/simple_table_buttons.html +0 -104
  138. data/unittests/html/simple_table_columns.html +0 -75
  139. data/unittests/html/table1.html +0 -179
  140. data/unittests/html/tableCell_using_xpath.html +0 -19
  141. data/unittests/html/table_and_tablerow_to_a.html +0 -174
  142. data/unittests/html/textarea.html +0 -30
  143. data/unittests/html/textfields1.html +0 -100
  144. data/unittests/html/textsearch.html +0 -44
  145. data/unittests/html/wallofcheckboxes.html +0 -1003
  146. data/unittests/html/xpath_nbsp.html +0 -11
  147. data/unittests/html/zeroindex.html +0 -11
  148. data/unittests/ie_exists_test.rb +0 -16
  149. data/unittests/ie_mock.rb +0 -94
  150. data/unittests/ie_test.rb +0 -54
  151. data/unittests/images_test.rb +0 -156
  152. data/unittests/images_xpath_test.rb +0 -90
  153. data/unittests/index_specifier_test.rb +0 -31
  154. data/unittests/js_events_test.rb +0 -31
  155. data/unittests/links_multi_test.rb +0 -34
  156. data/unittests/links_test.rb +0 -131
  157. data/unittests/links_xpath_test.rb +0 -38
  158. data/unittests/lists_test.rb +0 -23
  159. data/unittests/map_test.rb +0 -98
  160. data/unittests/minmax_test.rb +0 -37
  161. data/unittests/navigate_test.rb +0 -38
  162. data/unittests/nbsp_xpath_test.rb +0 -16
  163. data/unittests/no_wait_test.rb +0 -28
  164. data/unittests/non_core_tests.rb +0 -12
  165. data/unittests/other/all_tests_concurrent.rb +0 -57
  166. data/unittests/other/navigate_exception_test.rb +0 -24
  167. data/unittests/other/rexml_unit_test.rb +0 -27
  168. data/unittests/other/screen_capture_test.rb +0 -53
  169. data/unittests/other/testcase_method_order_test.rb +0 -36
  170. data/unittests/other/testcase_verify_test.rb +0 -25
  171. data/unittests/other/wait_until_test.rb +0 -102
  172. data/unittests/pagecontainstext_test.rb +0 -69
  173. data/unittests/parent_child_test.rb +0 -27
  174. data/unittests/perf_test.rb +0 -20
  175. data/unittests/pre_test.rb +0 -49
  176. data/unittests/radios_test.rb +0 -181
  177. data/unittests/radios_xpath_test.rb +0 -100
  178. data/unittests/security_setting_test.rb +0 -24
  179. data/unittests/selectbox_test.rb +0 -144
  180. data/unittests/selectbox_xpath_test.rb +0 -102
  181. data/unittests/setup.rb +0 -69
  182. data/unittests/speed_settings_test.rb +0 -67
  183. data/unittests/table_cell_using_xpath_test.rb +0 -34
  184. data/unittests/table_test.rb +0 -296
  185. data/unittests/table_xpath_test.rb +0 -109
  186. data/unittests/test_tests.rb +0 -9
  187. data/unittests/textarea_test.rb +0 -92
  188. data/unittests/textarea_xpath_test.rb +0 -77
  189. data/unittests/textfield_for_ch_char_test.rb +0 -32
  190. data/unittests/textfields_test.rb +0 -184
  191. data/unittests/textfields_xpath_test.rb +0 -110
  192. data/unittests/version_test.rb +0 -15
  193. data/unittests/win32ole_so_test.rb +0 -35
  194. data/unittests/window_tests.rb +0 -10
  195. data/unittests/windows/attach_to_existing_window_test.rb +0 -52
  196. data/unittests/windows/attach_to_new_window_test.rb +0 -74
  197. data/unittests/windows/close_window_test.rb +0 -20
  198. data/unittests/windows/frame_links_test.rb +0 -23
  199. data/unittests/windows/ie-each_test.rb +0 -46
  200. data/unittests/windows/modal_dialog_test.rb +0 -95
  201. data/unittests/windows/new_process_test.rb +0 -24
  202. data/unittests/windows/new_test.rb +0 -58
  203. data/unittests/windows/open_close_test.rb +0 -19
  204. data/unittests/windows/send_keys_test.rb +0 -26
  205. data/unittests/xpath_tests.rb +0 -11
  206. data/watir-rdoc.rb +0 -7
@@ -0,0 +1,7 @@
1
+ *~
2
+ .loadpath
3
+ .externalToolBuilders
4
+ pkg/
5
+ .idea/
6
+ .yardoc/
7
+ doc/
@@ -0,0 +1,3 @@
1
+ [submodule "spec/watirspec"]
2
+ path = spec/watirspec
3
+ url = git://github.com/watir/watirspec.git
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,5 @@
1
+ --readme README.rdoc
2
+ --no-private
3
+ --hide-void-return
4
+ --title "Watir Classic"
5
+ --files CHANGES,LICENSE
data/CHANGES CHANGED
@@ -1,4 +1,23 @@
1
- == 3.0.0.rc4 - 2012/04/23
1
+ == 3.1.0 - 2012/08/20
2
+
3
+ * Add Browser#name, which returns :ie.
4
+ * Add Dl#to_hash.
5
+ * Add support for Alert API (https://github.com/watir/watirspec/blob/master/alert_spec.rb).
6
+ * Add support for Browser#screenshot API (https://github.com/watir/watirspec/blob/master/screenshot_spec.rb).
7
+ * Browser#execute_script returns now correct Ruby objects instead of String.
8
+ * Browser#new accepts ignored parameter to make API more compatible with Watir-WebDriver.
9
+ * Element#drag_and_drop methods work also with elements not in the viewport.
10
+ * Fix TextField#set slow text entry.
11
+ * Remove all show_* methods. Use element collection methods with #each instead. For example browser.links.each {|link| puts link.href}.
12
+ * Remove already deprecated Watir::Waiter. Use Watir::Wait instead.
13
+ * Remove already deprecated WinClicker.
14
+ * Remove Browser#(javascript_)dialog. Use Browser#alert API instead.
15
+ * Remove ScreenCapture module. Use Browser#screenshot API instead.
16
+ * Remove Watir console. Use regular IRB or debugger instead.
17
+ * Remove Watir.log method, WatirLogger and DefaultLogger classes. Use standard Ruby Logger instead.
18
+ * Remove Watir.until_with_timeout. Use Watir::Wait.until instead.
19
+
20
+ == 3.0.0 - 2012/04/23
2
21
 
3
22
  * Browser#status returns an empty string if status bar is disabled in IE9
4
23
  * Browser#style fixed for IE9
@@ -6,9 +25,6 @@
6
25
  * #execute_script returns nil instead of 'undefined'
7
26
  * drag and drop fixed for IE9
8
27
  * Window#current? and Window#== are more robust
9
-
10
- == 3.0.0.rc3 - 2012/03/18
11
-
12
28
  * all html elements are now supported (even html5 ones)
13
29
  * CookieManager removed
14
30
  * cookies API support added (https://github.com/watir/watirspec/blob/master/cookies_spec.rb)
@@ -25,17 +41,11 @@
25
41
  * Table#row(s) and Table#cell(s) added which ignore inner tables - use #td/#tr for all.
26
42
  * raise an Exception if more locators are specified with :xpath/:css
27
43
  * searching by :xpath and :css code rewritten
28
-
29
- == 3.0.0.rc2 - 2012/02/04
30
-
31
44
  * Browser#textarea(s) method for searching <textarea> elements
32
45
  * Element#focus works with IE9
33
46
  * Element#focused? returns the state of focus on that element
34
47
  * Element#to_subtype returns Element if non-supported tag found instead of crashing
35
48
  * searching by :class will match now partially like other tools behave (e.g. jQuery)
36
-
37
- == 3.0.0.rc1 - 2012/01/13 - more conformance with WatirSpec
38
-
39
49
  * Button#text returns value if exists instead of text
40
50
  * Browser#goto prepends url automatically with http:// if scheme is missing
41
51
  * Browser#element(s)_by_(xpath/css) are now private methods - use #element(:css => ...) and #element(:xpath => ...) instead
@@ -0,0 +1,55 @@
1
+ This is an old, out of date list of our contributors, from an old README file.
2
+ Watir exists because of the help and assistance of many different people over the ages.
3
+ More recent contributors are acknowledged in the CHANGES file.
4
+
5
+ Contributors:
6
+ Bret Pettichord
7
+ Paul Rogers
8
+ Jonathan Kohl
9
+ Chris Morris
10
+ Karlin Fox
11
+ Lorenzo Jorquera
12
+ Atilla Ozgur
13
+ Justin McCarthy
14
+ Chris McMahon
15
+ Elisabeth Hendrickson
16
+ Michael Kelly
17
+ Peter Chau
18
+ Danny Faught
19
+ Andy Sipe
20
+ John Lloyd-Jones
21
+ Chris Hedges
22
+ Park Heesob
23
+ Shashank Date
24
+ Jared Luxenberg
25
+ Alexey Verkhovsky
26
+ Tuyet Cong-Ton-Nu
27
+ Jeff Wood
28
+ Angrez Singh
29
+ Abhishek Goliya
30
+ Yaxin Wang
31
+ Michael Bolton
32
+ Paul Carvalho
33
+ Konstantin Sobolev
34
+ David Schmidt
35
+ Dara Lillis
36
+ Charley Baker
37
+ Prema Arya
38
+ Xavier Noria
39
+ Jeff Fry
40
+ Zeljko Filipin
41
+ Paul Taylor - Bug fix 194
42
+ Vincent Xu - Chinese input support
43
+ Tomislav Car - Filefield fix (210)
44
+ Michael Hwee & Aidy Lewis - Multiple attribute support for FireWatir (233)
45
+ Alan Baird - Fix for visible? method (253)
46
+ Jari Bakken - Regexp support for includes? and selected? methods for select lists (261)
47
+
48
+ Acknowledgements:
49
+ Chris Morris
50
+ Brian Marick
51
+ Jonathan Kohl
52
+ Penny Tonita
53
+ Janet Gregory
54
+ Andy Tinkham
55
+ Jacinda Scott (logo creator)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ watir-classic (3.0.0)
5
+ ffi (~> 1.0)
6
+ nokogiri
7
+ rautomation (~> 0.7.2)
8
+ user-choices
9
+ win32-process (>= 0.5.5)
10
+ win32screenshot
11
+ windows-pr (>= 0.6.6)
12
+ yajl-ruby
13
+
14
+ GEM
15
+ remote: http://rubygems.org/
16
+ specs:
17
+ builder (3.0.0)
18
+ childprocess (0.3.4)
19
+ ffi (~> 1.0, >= 1.0.6)
20
+ diff-lcs (1.1.3)
21
+ ffi (1.1.3-x86-mingw32)
22
+ hoe (3.0.6)
23
+ rake (~> 0.8)
24
+ mini_magick (3.2.1)
25
+ subexec (~> 0.0.4)
26
+ nokogiri (1.5.5-x86-mingw32)
27
+ rack (1.4.1)
28
+ rack-protection (1.2.0)
29
+ rack
30
+ rake (0.9.2.2)
31
+ rautomation (0.7.2)
32
+ rspec (2.11.0)
33
+ rspec-core (~> 2.11.0)
34
+ rspec-expectations (~> 2.11.0)
35
+ rspec-mocks (~> 2.11.0)
36
+ rspec-core (2.11.1)
37
+ rspec-expectations (2.11.2)
38
+ diff-lcs (~> 1.1.3)
39
+ rspec-mocks (2.11.1)
40
+ s4t-utils (1.0.4)
41
+ hoe (>= 1.3.0)
42
+ sinatra (1.3.2)
43
+ rack (~> 1.3, >= 1.3.6)
44
+ rack-protection (~> 1.2)
45
+ tilt (~> 1.3, >= 1.3.3)
46
+ subexec (0.0.4)
47
+ syntax (1.0.0)
48
+ tilt (1.3.3)
49
+ user-choices (1.1.6.1)
50
+ builder (>= 2.1.2)
51
+ s4t-utils (>= 1.0.3)
52
+ xml-simple (>= 1.0.11)
53
+ win32-api (1.4.8-x86-mingw32)
54
+ win32-process (0.6.6)
55
+ windows-pr (>= 1.2.2)
56
+ win32screenshot (1.0.7)
57
+ ffi (~> 1.0)
58
+ mini_magick (~> 3.2.1)
59
+ rautomation (~> 0.7.0)
60
+ windows-api (0.4.2)
61
+ win32-api (>= 1.4.5)
62
+ windows-pr (1.2.2)
63
+ win32-api (>= 1.4.5)
64
+ windows-api (>= 0.3.0)
65
+ xml-simple (1.1.1)
66
+ yajl-ruby (1.1.0-x86-mingw32)
67
+ yard (0.8.2.1)
68
+
69
+ PLATFORMS
70
+ x86-mingw32
71
+
72
+ DEPENDENCIES
73
+ childprocess
74
+ rspec (~> 2.3)
75
+ sinatra
76
+ syntax
77
+ watir-classic!
78
+ yard
@@ -1,28 +1,22 @@
1
1
  = Watir Classic
2
2
 
3
- Watir, pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. It supports your app no matter what technology it is developed in. They support Internet Explorer on Windows, Firefox and Chrome on Windows, Mac and Linux and Safari on Mac.
3
+ Watir, pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers.
4
+ It supports your app no matter what technology it is developed in.
5
+ They support Internet Explorer on Windows, Firefox and Chrome on Windows, Mac and Linux and Safari on Mac.
4
6
 
5
7
  Project Home:: http://watir.com
6
- Source Code:: http://github.com/bret/watir
8
+ Source Code:: http://github.com/watir/watir-classic
7
9
  Support:: http://watir.com/support
8
- Gem:: https://rubygems.org/gems/watir
9
- Gem:: https://rubygems.org/gems/firewatir
10
- Gem:: https://rubygems.org/gems/commonwatir
11
- Gem:: https://rubygems.org/gems/safariwatir
12
- Gem:: https://rubygems.org/gems/watir-webdriver
13
- Gem:: https://rubygems.org/gems/celerity
10
+ Gem:: https://rubygems.org/gems/watir-classic
14
11
 
15
12
  == Install
16
13
 
17
- You have to install Ruby and RubyGems first. To be able to drive Firefox you have to install Firefox add-on. Detailed installation instructions are at http://watir.com/installation
18
-
19
- === Windows
20
-
21
- To install Internet Explorer and Firefox driver:
22
-
14
+ You have to install Ruby and RubyGems first.
23
15
  gem update --system
24
16
  gem install watir-classic
25
17
 
18
+ Detailed installation instructions are at http://watir.com/installation
19
+
26
20
  == Examples
27
21
 
28
22
  Some examples from http://watir.com/examples
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ task :default => :spec
7
+
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
12
+ spec.rcov = true
13
+ end
14
+
15
+ require 'yard'
16
+ YARD::Rake::YardocTask.new
17
+
18
+ #
19
+ # ------------------------------ watirspec -----------------------------------
20
+ #
21
+
22
+ if File.exist?(path = "spec/watirspec/watirspec.rake")
23
+ load path
24
+ end
25
+
26
+ namespace :watirspec do
27
+ desc 'Initialize and fetch the watirspec submodule'
28
+ task :init do
29
+ sh "git submodule init"
30
+ sh "git submodule update"
31
+ end
32
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.1.0
@@ -4,7 +4,6 @@
4
4
  # implementations.
5
5
 
6
6
  require 'watir-classic/version'
7
- require 'watir-classic/waiter' # this will be removed in some future version
8
7
  require 'watir-classic/wait'
9
8
  require 'watir-classic/wait_helper'
10
9
  require 'watir-classic/element_extensions'
@@ -0,0 +1,225 @@
1
+ // IEDialog.cpp : Defines the entry point for the DLL application.
2
+ //
3
+
4
+ #include "stdafx.h"
5
+ #include "IEDialog.h"
6
+
7
+ BOOL APIENTRY DllMain( HANDLE hModule,
8
+ DWORD ul_reason_for_call,
9
+ LPVOID lpReserved
10
+ )
11
+ {
12
+ return TRUE;
13
+ }
14
+
15
+ void ShowString(LPCTSTR dialogName)
16
+ {
17
+ MessageBox(NULL, dialogName, "Note", MB_OK);
18
+ }
19
+
20
+ void DoElementClick(LPCTSTR windowName, LPCTSTR elementId)
21
+ {
22
+ DoClick(windowName, elementId, NULL);
23
+ }
24
+
25
+ void DoButtonClick(LPCTSTR windowName, LPCTSTR buttonName)
26
+ {
27
+ DoClick(windowName, NULL, buttonName);
28
+ }
29
+
30
+ void DoClick(LPCTSTR windowName, LPCTSTR elementId, LPCTSTR elementName)
31
+ {
32
+ MessageBox(NULL, "Started", "Info", MB_OK);
33
+ CoInitialize( NULL );
34
+
35
+ IHTMLDocument2* pDoc2 = NULL;
36
+ pDoc2 = GetDoc2(windowName);
37
+
38
+ if(pDoc2 != NULL)
39
+ {
40
+ IHTMLElement* pElem = FindElement(pDoc2, elementId, elementName);
41
+ if(pElem != NULL)
42
+ {
43
+ pElem->click();
44
+ pElem->Release();
45
+ }
46
+
47
+ pDoc2->Release();
48
+ }
49
+
50
+ CoUninitialize();
51
+ }
52
+
53
+ void GetUnknown(HWND hWindow, int* pOut)
54
+ {
55
+ *pOut = 0;
56
+
57
+ HINSTANCE hInst = ::LoadLibrary( TEXT("OLEACC.DLL") );
58
+ if(hInst == NULL)
59
+ {
60
+ MessageBox(NULL, "Cannot load Miscrosoft Active Accessibility", "Error", MB_OK);
61
+ return;
62
+ }
63
+
64
+ HWND hWndChild=NULL;
65
+ // Get 1st document window
66
+ ::EnumChildWindows(hWindow, EnumChildProc, (LPARAM)&hWndChild );
67
+
68
+ IUnknown* pUnknown = NULL;
69
+
70
+ LRESULT lRes;
71
+ UINT nMsg = ::RegisterWindowMessage(TEXT("WM_HTML_GETOBJECT") );
72
+ ::SendMessageTimeout( hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes );
73
+ LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, TEXT("ObjectFromLresult") );
74
+ if ( pfObjectFromLresult != NULL )
75
+ {
76
+ HRESULT hr;
77
+ hr=pfObjectFromLresult(lRes,IID_IUnknown,0,(void**)&pUnknown);
78
+
79
+ if ( SUCCEEDED(hr) ){
80
+ *pOut = (int)pUnknown;
81
+ }
82
+ }
83
+ }
84
+
85
+ IHTMLDocument2* GetDoc2(LPCTSTR windowName)
86
+ {
87
+ HWND hWindow = ::FindWindow(NULL, windowName);
88
+ if(hWindow == NULL)
89
+ {
90
+ MessageBox(NULL, "Cannot find window", "Error", MB_OK);
91
+ return NULL;
92
+ }
93
+
94
+ HINSTANCE hInst = ::LoadLibrary( TEXT("OLEACC.DLL") );
95
+ if(hInst == NULL)
96
+ {
97
+ MessageBox(NULL, "Cannot load Miscrosoft Active Accessibility", "Error", MB_OK);
98
+ return NULL;
99
+ }
100
+
101
+ HWND hWndChild=NULL;
102
+ // Get 1st document window
103
+ ::EnumChildWindows(hWindow, EnumChildProc, (LPARAM)&hWndChild );
104
+
105
+ IHTMLDocument2* pDoc2=NULL;
106
+
107
+ CComPtr<IHTMLDocument> spDoc=NULL;
108
+
109
+ LRESULT lRes;
110
+ UINT nMsg = ::RegisterWindowMessage(TEXT("WM_HTML_GETOBJECT") );
111
+ ::SendMessageTimeout( hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes );
112
+ LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, TEXT("ObjectFromLresult") );
113
+ if ( pfObjectFromLresult != NULL )
114
+ {
115
+ HRESULT hr;
116
+ hr=pfObjectFromLresult(lRes,IID_IHTMLDocument,0,(void**)&spDoc);
117
+
118
+ if ( SUCCEEDED(hr) ){
119
+ CComPtr<IDispatch> spDisp;
120
+ CComQIPtr<IHTMLWindow2> spWin;
121
+
122
+ hr = spDoc->get_Script( &spDisp );
123
+
124
+ spWin = spDisp;
125
+ spWin->get_document( &pDoc2 );
126
+ }
127
+ }
128
+
129
+ return pDoc2;
130
+ }
131
+
132
+ BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
133
+ {
134
+ TCHAR buf[100];
135
+
136
+ ::GetClassName( hwnd, (LPTSTR)&buf, 100 );
137
+ if ( _tcscmp( buf, _T("Internet Explorer_Server") ) == 0 )
138
+ {
139
+ *(HWND*)lParam = hwnd;
140
+ return FALSE;
141
+ }
142
+ else
143
+ return TRUE;
144
+ }
145
+
146
+ IHTMLElement* FindElement(IHTMLDocument2* pDoc2, LPCTSTR elementId, LPCTSTR elementName)
147
+ {
148
+ USES_CONVERSION;
149
+ HRESULT hr;
150
+
151
+ //Enumerate the HTML elements
152
+ IHTMLElementCollection* pColl = NULL;
153
+ hr = pDoc2->get_all( &pColl );
154
+ if (hr == S_OK && pColl != NULL)
155
+ {
156
+ LONG celem;
157
+ pColl->get_length( &celem );
158
+
159
+ //Loop through each elment
160
+ for ( int i=0; i< celem; i++ )
161
+ {
162
+ VARIANT varIndex;
163
+ varIndex.vt = VT_UINT;
164
+ varIndex.lVal = i;
165
+ VARIANT var2;
166
+ VariantInit( &var2 );
167
+
168
+ IDispatch* pDisp;
169
+
170
+ hr = pColl->item( varIndex, var2, &pDisp );//Get an element
171
+
172
+ if ( hr == S_OK )
173
+ {
174
+ IHTMLElement* pElem;
175
+ //Ask for an HTMLElemnt interface
176
+ hr = pDisp->QueryInterface(IID_IHTMLElement, (void **)&pElem);
177
+
178
+ if ( hr == S_OK )
179
+ {
180
+ if(elementId != NULL) //find element by Id
181
+ {
182
+ BSTR bstr;
183
+ //Get the id of the element
184
+ pElem->get_id(&bstr);
185
+
186
+ LPCTSTR id = OLE2T(bstr);
187
+
188
+ if(_tcscmp(id, elementId))
189
+ {
190
+ return pElem;
191
+ }
192
+ }
193
+ else if(elementName != NULL) //find element by Name
194
+ {
195
+ IHTMLInputButtonElement* pButton;
196
+ hr = pDisp->QueryInterface(IID_IHTMLInputButtonElement,(void **)&pButton);
197
+ if ( hr == S_OK )
198
+ {
199
+ BSTR bstr;
200
+ //Get the name of the element
201
+ pButton->get_name(&bstr);
202
+
203
+ LPCTSTR name = OLE2T(bstr);
204
+
205
+ if(_tcscmp(name, elementName))
206
+ {
207
+ return pElem;
208
+ }
209
+ }
210
+ }
211
+
212
+ pElem->Release();
213
+ }
214
+ }
215
+ }
216
+
217
+ pColl->Release();
218
+ }
219
+
220
+ return NULL;
221
+ }
222
+
223
+
224
+
225
+