operawatir 0.3-jruby

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/.gitmodules +3 -0
  2. data/.yardopts +5 -0
  3. data/AUTHORS +7 -0
  4. data/Gemfile +9 -0
  5. data/LICENSE +30 -0
  6. data/README.md +158 -0
  7. data/Rakefile +59 -0
  8. data/VERSION +1 -0
  9. data/bin/desktopwatir +106 -0
  10. data/bin/operawatir +95 -0
  11. data/lib/operadriver/APACHE_2.0_LICENSE.txt +204 -0
  12. data/lib/operadriver/NEW_BSD_LICENSE.txt +36 -0
  13. data/lib/operadriver/commons-jxpath-1.3.jar +0 -0
  14. data/lib/operadriver/protobuf-java-2.3.0.jar +0 -0
  15. data/lib/operadriver/selenium-common.jar +0 -0
  16. data/lib/operadriver/webdriver-opera.jar +0 -0
  17. data/lib/operawatir.rb +46 -0
  18. data/lib/operawatir/browser.rb +181 -0
  19. data/lib/operawatir/collection.rb +133 -0
  20. data/lib/operawatir/compat.rb +25 -0
  21. data/lib/operawatir/compat/browser.rb +20 -0
  22. data/lib/operawatir/compat/collection.rb +99 -0
  23. data/lib/operawatir/compat/deprecation.rb +46 -0
  24. data/lib/operawatir/compat/element.rb +165 -0
  25. data/lib/operawatir/compat/element_finders.rb +159 -0
  26. data/lib/operawatir/compat/window.rb +27 -0
  27. data/lib/operawatir/element.rb +228 -0
  28. data/lib/operawatir/exceptions.rb +38 -0
  29. data/lib/operawatir/helper.rb +53 -0
  30. data/lib/operawatir/selector.rb +111 -0
  31. data/lib/operawatir/version.rb +15 -0
  32. data/lib/operawatir/window.rb +174 -0
  33. data/spec/fire_event/fire_event.rb +268 -0
  34. data/spec/fire_event/interactive/onBlur.html +45 -0
  35. data/spec/fire_event/interactive/onChange.html +47 -0
  36. data/spec/fire_event/interactive/onClick.html +45 -0
  37. data/spec/fire_event/interactive/onDblClick.html +45 -0
  38. data/spec/fire_event/interactive/onFocus.html +45 -0
  39. data/spec/fire_event/interactive/onMouseDown.html +45 -0
  40. data/spec/fire_event/interactive/onMouseMove.html +45 -0
  41. data/spec/fire_event/interactive/onMouseOut.html +45 -0
  42. data/spec/fire_event/interactive/onMouseOver.html +45 -0
  43. data/spec/fire_event/interactive/onMouseUp.html +45 -0
  44. data/spec/fire_event/interactive/onScroll.html +14 -0
  45. data/spec/legacy_watirspec/area_spec.rb +106 -0
  46. data/spec/legacy_watirspec/areas_spec.rb +38 -0
  47. data/spec/legacy_watirspec/browser_spec.rb +297 -0
  48. data/spec/legacy_watirspec/button_spec.rb +260 -0
  49. data/spec/legacy_watirspec/buttons_spec.rb +54 -0
  50. data/spec/legacy_watirspec/checkbox_spec.rb +280 -0
  51. data/spec/legacy_watirspec/checkboxes_spec.rb +38 -0
  52. data/spec/legacy_watirspec/collections_spec.rb +18 -0
  53. data/spec/legacy_watirspec/dd_spec.rb +140 -0
  54. data/spec/legacy_watirspec/dds_spec.rb +38 -0
  55. data/spec/legacy_watirspec/del_spec.rb +181 -0
  56. data/spec/legacy_watirspec/dels_spec.rb +62 -0
  57. data/spec/legacy_watirspec/div_spec.rb +244 -0
  58. data/spec/legacy_watirspec/divs_spec.rb +38 -0
  59. data/spec/legacy_watirspec/dl_spec.rb +140 -0
  60. data/spec/legacy_watirspec/dls_spec.rb +38 -0
  61. data/spec/legacy_watirspec/dt_spec.rb +140 -0
  62. data/spec/legacy_watirspec/dts_spec.rb +38 -0
  63. data/spec/legacy_watirspec/element_spec.rb +86 -0
  64. data/spec/legacy_watirspec/em_spec.rb +114 -0
  65. data/spec/legacy_watirspec/ems_spec.rb +38 -0
  66. data/spec/legacy_watirspec/filefield_spec.rb +127 -0
  67. data/spec/legacy_watirspec/filefields_spec.rb +38 -0
  68. data/spec/legacy_watirspec/fixtures/2000_spans.html +2009 -0
  69. data/spec/legacy_watirspec/fixtures/bug_duplicate_attributes.html +14 -0
  70. data/spec/legacy_watirspec/fixtures/bug_javascript_001.html +11 -0
  71. data/spec/legacy_watirspec/fixtures/buttons_with_duplicate_ids.html +18 -0
  72. data/spec/legacy_watirspec/fixtures/collections.html +15 -0
  73. data/spec/legacy_watirspec/fixtures/definition_lists.html +48 -0
  74. data/spec/legacy_watirspec/fixtures/euc-jp_text.html +17 -0
  75. data/spec/legacy_watirspec/fixtures/forms_with_input_elements.html +126 -0
  76. data/spec/legacy_watirspec/fixtures/frame_1.html +18 -0
  77. data/spec/legacy_watirspec/fixtures/frame_2.html +16 -0
  78. data/spec/legacy_watirspec/fixtures/frames.html +11 -0
  79. data/spec/legacy_watirspec/fixtures/iframes.html +12 -0
  80. data/spec/legacy_watirspec/fixtures/images.html +27 -0
  81. data/spec/legacy_watirspec/fixtures/images/1.gif +0 -0
  82. data/spec/legacy_watirspec/fixtures/images/2.gif +0 -0
  83. data/spec/legacy_watirspec/fixtures/images/3.gif +0 -0
  84. data/spec/legacy_watirspec/fixtures/images/button.jpg +0 -0
  85. data/spec/legacy_watirspec/fixtures/images/circle.jpg +0 -0
  86. data/spec/legacy_watirspec/fixtures/images/map.gif +0 -0
  87. data/spec/legacy_watirspec/fixtures/images/map2.gif +0 -0
  88. data/spec/legacy_watirspec/fixtures/images/minus.gif +0 -0
  89. data/spec/legacy_watirspec/fixtures/images/originaltriangle.jpg +0 -0
  90. data/spec/legacy_watirspec/fixtures/images/plus.gif +0 -0
  91. data/spec/legacy_watirspec/fixtures/images/square.jpg +0 -0
  92. data/spec/legacy_watirspec/fixtures/images/triangle.jpg +0 -0
  93. data/spec/legacy_watirspec/fixtures/iso-2022-jp_text.html +17 -0
  94. data/spec/legacy_watirspec/fixtures/javascript/helpers.js +16 -0
  95. data/spec/legacy_watirspec/fixtures/jquery.html +28 -0
  96. data/spec/legacy_watirspec/fixtures/latin1_text.html +17 -0
  97. data/spec/legacy_watirspec/fixtures/multiple_ids.html +14 -0
  98. data/spec/legacy_watirspec/fixtures/non_control_elements.html +135 -0
  99. data/spec/legacy_watirspec/fixtures/parser_bug_001.html +12 -0
  100. data/spec/legacy_watirspec/fixtures/prevent_form_submit.html +20 -0
  101. data/spec/legacy_watirspec/fixtures/right_click.html +11 -0
  102. data/spec/legacy_watirspec/fixtures/shift_jis_text.html +17 -0
  103. data/spec/legacy_watirspec/fixtures/tables.html +121 -0
  104. data/spec/legacy_watirspec/fixtures/timeout.html +16 -0
  105. data/spec/legacy_watirspec/fixtures/timeout_window_location.html +19 -0
  106. data/spec/legacy_watirspec/fixtures/tiny_mce.html +27 -0
  107. data/spec/legacy_watirspec/fixtures/utf8_text.html +15 -0
  108. data/spec/legacy_watirspec/fixtures/watirspec.css +0 -0
  109. data/spec/legacy_watirspec/form_spec.rb +73 -0
  110. data/spec/legacy_watirspec/forms_spec.rb +39 -0
  111. data/spec/legacy_watirspec/frame_spec.rb +161 -0
  112. data/spec/legacy_watirspec/frames_spec.rb +75 -0
  113. data/spec/legacy_watirspec/guards.rb +38 -0
  114. data/spec/legacy_watirspec/hidden_spec.rb +120 -0
  115. data/spec/legacy_watirspec/hiddens_spec.rb +38 -0
  116. data/spec/legacy_watirspec/hn_spec.rb +101 -0
  117. data/spec/legacy_watirspec/hns_spec.rb +39 -0
  118. data/spec/legacy_watirspec/image_spec.rb +237 -0
  119. data/spec/legacy_watirspec/images_spec.rb +38 -0
  120. data/spec/legacy_watirspec/ins_spec.rb +181 -0
  121. data/spec/legacy_watirspec/inses_spec.rb +62 -0
  122. data/spec/legacy_watirspec/label_spec.rb +85 -0
  123. data/spec/legacy_watirspec/labels_spec.rb +38 -0
  124. data/spec/legacy_watirspec/li_spec.rb +135 -0
  125. data/spec/legacy_watirspec/link_spec.rb +194 -0
  126. data/spec/legacy_watirspec/links_spec.rb +39 -0
  127. data/spec/legacy_watirspec/lis_spec.rb +38 -0
  128. data/spec/legacy_watirspec/map_spec.rb +100 -0
  129. data/spec/legacy_watirspec/maps_spec.rb +38 -0
  130. data/spec/legacy_watirspec/meta_spec.rb +26 -0
  131. data/spec/legacy_watirspec/metas_spec.rb +36 -0
  132. data/spec/legacy_watirspec/ol_spec.rb +86 -0
  133. data/spec/legacy_watirspec/ols_spec.rb +38 -0
  134. data/spec/legacy_watirspec/option_spec.rb +187 -0
  135. data/spec/legacy_watirspec/p_spec.rb +167 -0
  136. data/spec/legacy_watirspec/pre_spec.rb +133 -0
  137. data/spec/legacy_watirspec/pres_spec.rb +38 -0
  138. data/spec/legacy_watirspec/ps_spec.rb +38 -0
  139. data/spec/legacy_watirspec/radio_spec.rb +286 -0
  140. data/spec/legacy_watirspec/radios_spec.rb +35 -0
  141. data/spec/legacy_watirspec/select_list_spec.rb +326 -0
  142. data/spec/legacy_watirspec/select_lists_spec.rb +39 -0
  143. data/spec/legacy_watirspec/server.rb +91 -0
  144. data/spec/legacy_watirspec/span_spec.rb +181 -0
  145. data/spec/legacy_watirspec/spans_spec.rb +64 -0
  146. data/spec/legacy_watirspec/spec_helper.rb +12 -0
  147. data/spec/legacy_watirspec/strong_spec.rb +97 -0
  148. data/spec/legacy_watirspec/strongs_spec.rb +39 -0
  149. data/spec/legacy_watirspec/table_bodies_spec.rb +61 -0
  150. data/spec/legacy_watirspec/table_body_spec.rb +119 -0
  151. data/spec/legacy_watirspec/table_cell_spec.rb +76 -0
  152. data/spec/legacy_watirspec/table_cells_spec.rb +71 -0
  153. data/spec/legacy_watirspec/table_footer_spec.rb +94 -0
  154. data/spec/legacy_watirspec/table_footers_spec.rb +61 -0
  155. data/spec/legacy_watirspec/table_header_spec.rb +98 -0
  156. data/spec/legacy_watirspec/table_headers_spec.rb +59 -0
  157. data/spec/legacy_watirspec/table_row_spec.rb +104 -0
  158. data/spec/legacy_watirspec/table_rows_spec.rb +64 -0
  159. data/spec/legacy_watirspec/table_spec.rb +170 -0
  160. data/spec/legacy_watirspec/tables_spec.rb +40 -0
  161. data/spec/legacy_watirspec/text_field_spec.rb +315 -0
  162. data/spec/legacy_watirspec/text_fields_spec.rb +38 -0
  163. data/spec/legacy_watirspec/ul_spec.rb +84 -0
  164. data/spec/legacy_watirspec/uls_spec.rb +40 -0
  165. data/spec/legacy_watirspec/watir_compatibility_spec.rb +176 -0
  166. data/spec/legacy_watirspec/watirspec_helper.rb +57 -0
  167. data/utils/Rakefile +79 -0
  168. data/utils/launchers/launcher-linux-i686 +0 -0
  169. data/utils/launchers/launcher-linux-x86_64 +0 -0
  170. data/utils/launchers/launcher-win32-i86pc.exe +0 -0
  171. metadata +404 -0
@@ -0,0 +1,3 @@
1
+ [submodule "spec/new_watirspec"]
2
+ path = spec/new_watirspec
3
+ url = ssh://dvcs.oslo.osa/var/git/core-systems/watirspec.git
@@ -0,0 +1,5 @@
1
+ --no-private
2
+ --title "OperaWatir"
3
+ --exclude bin/desktopwatir
4
+ --exclude lib/operawatir/desktop*
5
+ --exclude lib/operawatir/quickwidget*
data/AUTHORS ADDED
@@ -0,0 +1,7 @@
1
+ Karianne Ekern <karianne.ekern@opera.com>
2
+ Stuart Knightley <stuartk@opera.com>
3
+ Chris Lloyd <christopherl@opera.com>
4
+ Adam Minchinton <adamm@opera.com>
5
+ Andreas Tolf Tolfsen <andreastt@opera.com>
6
+ Deniz Turkoglu <dturkoglu@opera.com>
7
+
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :rubygems
2
+ #gemspec
3
+
4
+ group :development do
5
+ gem "bundler", "~> 1.0.0"
6
+ gem "jeweler", "~> 1.5.1"
7
+ gem "rcov", ">= 0"
8
+ end
9
+
data/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ Copyright (c) 2010 Opera Software ASA
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the
14
+ distribution.
15
+
16
+ 3. Neither the name of Opera Software ASA nor the names of its
17
+ contributors may be used to endorse or promote products derived
18
+ from this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPERA SOFTWARE
24
+ ASA BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,158 @@
1
+ # Readme
2
+
3
+ [OperaWatir](http://operawatir.org/) is a part of the [Watir](http://watir.com/) (pronounced _water_) family of free software Ruby libraries for automating web browsers. OperaWatir provides a querying engine and Ruby bindings for a backend Java library, OperaDriver, for driving the [Opera web browser](http://opera.com/). It aims for full compliance with the [watirspec](https://github.com/jarib/watirspec) specification.
4
+
5
+ License:: [New BSD](https://github.com/operasoftware/operawatir/blob/master/LICENSE)
6
+ Project Home:: [http://operawatir.org/](http://operawatir.org/)
7
+ Source Code:: [https://github.com/operasoftware/operawatir](https://github.com/operasoftware/operawatir)
8
+ Mailing List:: [https://list.opera.com/mailman/listinfo/operawatir-users](https://list.opera.com/mailman/listinfo/operawatir-users)
9
+ Issues:: [https://github.com/operasoftware/operawatir/issues](https://github.com/operasoftware/operawatir/issues)
10
+ Gem:: [https://rubygems.org/operawatir](http://rubygems.org/gems/operawatir)
11
+
12
+ ## Third-Party Libraries
13
+
14
+ OperaDriver uses the following third-party Java libraries:
15
+
16
+ - [Google protobuf](http://code.google.com/p/protobuf/) (New BSD License)
17
+ - [Apache Commons JXPath](http://commons.apache.org/jxpath/) (Apache 2.0 License)
18
+
19
+ More information about the New BSD (AKA Modified BSD or BSD-3) and Apache 2.0 licenses can be found in the appropriate text files in ``lib/operadriver``.
20
+
21
+ OperaWatir uses the following libraries:
22
+
23
+ - [rspec](https://github.com/rspec/rspec) (MIT License)
24
+ - [jeweler](https://github.com/technicalpickles/jeweler) (MIT License)
25
+ - [rake](https://github.com/jimweirich/rake) (MIT License)
26
+ - [yard](https://github.com/lsegal/yard) (MIT License)
27
+ - [mongrel](http://rubyforge.org/projects/mongrel) (Ruby License)
28
+ - [sinatra](http://www.sinatrarb.com/) (MIT License)
29
+ - [rr](http://rubyforge.org/projects/double-ruby) (MIT License)
30
+
31
+ ## Install
32
+
33
+ ### Requirements
34
+
35
+ OperaWatir runs on GNU/Linux and Windows operating systems. Other UNIX-like systems, such as BSD and OS X, are not currently supported, but support is planned. Required dependencies are _Java_ >= 1.6.0, _JRuby_ >= 1.5.1 (ruby 1.8.7 patchlevel 249), _RubyGems_ >= 1.3.5, _RSpec_ >= 2.0.0, and a somewhat recent desktop or nightly build of Opera.
36
+
37
+ ### Installation procedure
38
+
39
+ Make sure that you have the right requirements for installing and running OperaWatir. Please note that OperaWatir will only run on the JRuby platform. For more detailed installation instructions, please see our [Getting Started](http://operasoftware.github.com/operawatir/tutorial.html) guide.
40
+
41
+ To install (leave out the “sudo” command if you're installing on Windows):
42
+
43
+ % sudo jruby -S gem install operawatir
44
+
45
+ Next, make sure that JRuby's ``bin`` directory is a part of your ``PATH`` environmental variable on GNU/Linux.
46
+
47
+ ## Limitations
48
+
49
+ __Before you get started playing with OperaWatir, there are a few important things you need to keep in mind.__
50
+
51
+ This is a __pre-release__ of OperaWatir (0.3), and should not be considered stable or suitable for use in production. It should be treated as a proof of concept.
52
+
53
+ It is not possible to run OperaWatir without specifying the ``OPERA_PATH`` (full path to Opera binary) and ``OPERA_LAUNCHER`` (full path to Opera launcher binary) environmental variables.
54
+
55
+ Since the launcher applications are not shipped with the latest public release of Opera, we have bundled them with the gem. They can be found in ``./utils/launchers/`` under the gem's directory (typically ``/usr/lib/jruby/lib/ruby/gems/1.8/gems/operawatir-0.3-java/utils/launchers/`` on GNU/Linux systems and ``C:\\JRuby-1.5.2\\lib\\ruby\\gems\\1.8\\gems\\operawatir-0.3-java\\utils\\launchers\\`` on Windows). The launchers provided will work on 32-bit GNU/Linux and Windows operating systems. OS X support is planned.
56
+
57
+ ## Examples
58
+
59
+ The Watir API allows you to write scripts that interact with any web page. Its primary purpose is to ease test automation for web applications. Your scripts can, for example, before you deploy automatically go through all the steps your users normally would and alert you of any regressions.
60
+
61
+ Let's take a closer look at how this works.
62
+
63
+ require 'rubygems'
64
+ require 'operawatir'
65
+
66
+ browser = OperaWatir::Browser.new
67
+
68
+ browser.goto 'http://en.wikipedia.org/'
69
+ browser.text_field(:id => 'searchInput').set 'Opera'
70
+ browser.button(:id => 'searchButton').click
71
+
72
+ The script above will tell the browser to load the front page of Wikipedia, write “Opera” in the search field and click the search button. If all goes as intended, the browser will end up at a relevant article.
73
+
74
+ To run the script, use the following command:
75
+
76
+ % jruby example.rb
77
+
78
+ As Watir scripts are run in a full-featured browser, all keypresses and clicks will be interpreted as if they were real, and invoke attached JavaScript event listeners. If we want to test the JavaScript-powered suggestion feature on the Wikipedia search box, we can do this:
79
+
80
+ require 'rubygems'
81
+ require 'operawatir'
82
+
83
+ browser = OperaWatir::Browser.new
84
+
85
+ browser.goto 'http://en.wikipedia.org/'
86
+ browser.text_field(:id => 'searchInput').click
87
+ browser.type 'Hello world'
88
+ browser.key 'Down'
89
+ browser.key 'Enter'
90
+
91
+ The first suggested link will be selected by pressing arrow down (``'Down'``) and navigated to (``'Enter'``). Using the same key events, you could even teach a script to play platform games:
92
+
93
+ require 'rubygems'
94
+ require 'operawatir'
95
+
96
+ browser.goto 'http://www.phoboslab.org/biolab/'
97
+ sleep 2
98
+ browser.key 'X'
99
+ sleep 1
100
+ browser.key_down 'Right'
101
+ 5.times { browser.key 'X' }
102
+ 2.times { browser.key 'C' }
103
+ browser.key_up 'Right'
104
+
105
+ Sending commands to the browser is great, but sometimes we want to get something back too. The following lines of code will have the browser automatically look up the phone number of Opera Software in the [yellow pages](http://gulesider.no/) and write it to the console.
106
+
107
+ require 'rubygems'
108
+ require 'operawatir'
109
+
110
+ browser = OperaWatir::Browser.new
111
+
112
+ browser.goto 'http://gulesider.no/'
113
+ browser.text_field(:name => 'search_word').set 'Opera Software'
114
+ browser.button(:name => 'btn_cs').click
115
+ puts browser.li(:class => 'tel').text
116
+
117
+ When running proper functional tests on your web application with Watir, you might want a bit more structured output. To define assertions and get pretty test reports, you can use [RSpec](http://rspec.info/), a behaviour-driven testing framework.
118
+
119
+ When writing test suites you can use the OperaWatir::Helper class to help ease some tasks, such as constructing and tearing down the Browser object. A simple test suite looks like this:
120
+
121
+ describe 'Yellow Pages' do
122
+ before :each do
123
+ browser.goto 'http://gulesider.no/'
124
+ end
125
+
126
+ it 'finds the phone number to Opera Software' do
127
+ browser.text_field(:name => 'search_word').set 'Opera Software'
128
+ browser.button(:name => 'btn_cs').click
129
+ browser.li(:class => 'tel').text.should == '24 16 40 00'
130
+ end
131
+
132
+ it 'finds the phone number to the Norwegian Opera and Ballet' do
133
+ browser.text_field(:name => 'search_word').set 'Den Norske Opera'
134
+ browser.button(:name => 'btn_cs').click
135
+ browser.li(:class => 'tel').text.should == '21 42 21 00'
136
+ end
137
+ end
138
+
139
+ Since this is an RSpec test you can run it using the operawatir binary, which is simply a shortcut for running tests:
140
+
141
+ % operawatir yellow_pages.rb
142
+
143
+ Each block of code corresponds to a single named test case returning PASS or FAIL. Whether you got back the expected and correct return value is evaluated with ``.should``. If all tests pass, you will see the following output:
144
+
145
+ ..
146
+
147
+ Finished in 2.04 seconds
148
+ 2 examples, 0 failures
149
+
150
+ If anything fails, more information about each failure will be provided.
151
+
152
+ ## Merry Christmas!
153
+
154
+ Despite its shortcomings, we hope you will enjoy playing around with the Watir libraries for using OperaDriver driving Opera. We decided that we would rather see it go out to the public before Christmas than waiting for another month or two until it is pristine and perfect.
155
+
156
+ One of the things we are most excited about is the new Watir 2 API that we have made a prototype implementation of, which is based on [Jari Bakken's ideas for a new API](https://github.com/jarib/watir-webdriver/wiki/Comparison-with-Watir-1.X). On top of this, we have written a Watir 1 compatibility layer which is switched on by default. We are looking forward to the design discussions that this will bring. Oh, and by the way, will you be able to find the magic switch for Watir 2? (-;
157
+
158
+ We hope you'll enjoy this little Christmas gift! Furthermore, we wish you a Merry Christmas and a Happy New Year from us here at Opera Software in Oslo!
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rake/clean'
3
+ require 'jeweler'
4
+ require 'rspec/core/rake_task'
5
+ require 'yard/rake/yardoc_task'
6
+
7
+ require './lib/operawatir/version'
8
+
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = 'operawatir'
11
+ gem.version = OperaWatir.version
12
+ gem.date = Date.today.to_s
13
+
14
+ gem.authors = ['Deniz Turkoglu', 'Andreas Tolf Tolfsen', 'Chris Lloyd', 'Stuart Knightley']
15
+ gem.email = ['dturkoglu@opera.com', 'andreastt@opera.com', 'christopherl@opera.com', 'stuartk@opera.com']
16
+ gem.homepage = 'http://operasoftware.github.com/operawatir'
17
+ gem.summary = 'Toolkit for automating interactions with the Opera web browser.'
18
+ gem.description = <<-EOF
19
+ OperaWatir is a part of the Watir (pronounced water) family of
20
+ free software Ruby libraries for automating web
21
+ browsers. OperaWatir provides a querying engine and Ruby bindings
22
+ for a backend Java library, OperaDriver, for driving the Opera web
23
+ browser. It aims for full compliancy with the watirspec
24
+ specification.
25
+ EOF
26
+
27
+ gem.rubyforge_project = gem.name
28
+
29
+ gem.platform = 'jruby'
30
+ gem.has_rdoc = true
31
+ gem.extra_rdoc_files = ['README.md']
32
+
33
+ gem.add_dependency 'rspec', '>= 2'
34
+
35
+ gem.add_development_dependency 'jeweler'
36
+ gem.add_development_dependency 'rake'
37
+ gem.add_development_dependency 'yard'
38
+ gem.add_development_dependency 'mongrel', '>= 1.1.5'
39
+ gem.add_development_dependency 'sinatra', '>= 1.1'
40
+ gem.add_development_dependency 'rr'
41
+
42
+ gem.files.exclude '.gitignore'
43
+ gem.files.exclude 'bin/desktopwatir'
44
+ gem.files.exclude 'lib/operawatir/desktop*.rb'
45
+ gem.files.exclude 'lib/operawatir/quickwidgets'
46
+ end
47
+
48
+ CLEAN.add 'pkg'
49
+
50
+ RSpec::Core::RakeTask.new do |t|
51
+ end
52
+
53
+ YARD::Rake::YardocTask.new do |t|
54
+ t.options = ['--no-private']
55
+ end
56
+
57
+ task :doc => :yard
58
+
59
+ CLEAN.add 'doc'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ require 'rubygems'
4
+
5
+ require 'optparse'
6
+ require 'ostruct'
7
+ require 'rbconfig'
8
+ require 'rspec'
9
+ require 'operawatir'
10
+
11
+ class Options
12
+
13
+ def self.parse(args)
14
+ options = OpenStruct.new
15
+
16
+ options.ng = false
17
+ options.inspectr = ENV['OPERA_INSPECTR'] || ''
18
+ options.color = Config::CONFIG['host_os'] =~ /mswin|msys|mingw32/ ? false : true
19
+ options.check_syntax = false
20
+ options.format = 'progress'
21
+ options.executable = ENV['OPERA_PATH'] || ''
22
+ options.options = ENV['OPERA_ARGS'] || ''
23
+
24
+ opts = OptionParser.new do |opts|
25
+ opts.banner = "Usage: operawatir [--ng] [-i|--inspectr] [--color] [-c|--check-syntax]\n" +
26
+ " [-f|--format=FORMAT[:OUT_FILE]] [-e|--executable=BINARY] [-o|--options=OPTIONS]\n" +
27
+ " [-h|--help] [-v|--version] FILES"
28
+
29
+ opts.separator ""
30
+ opts.separator "Specific options:"
31
+
32
+ opts.on('--ng', 'Connect to Nailgun server instead of starting our ',
33
+ 'own JVM') do |ng|
34
+ options.ng = ng
35
+ end
36
+
37
+ opts.on('-i', '--inspectr', 'Attach inspectr to browser instance') do |i|
38
+ options.inspectr = i
39
+ end
40
+
41
+ opts.on('--color', 'Enable colorized output (default: enabled)') do |c|
42
+ options.color = c
43
+ end
44
+
45
+ opts.on('-c', '--check-syntax', 'Check syntax only') do |c|
46
+ options.check_syntax = c
47
+ end
48
+
49
+ opts.on('-f', '--format=FORMAT[:OUT_FILE]',
50
+ [:OperaHelperFormatter, :SpartanFormatter, :progress,
51
+ :documentation],
52
+ 'Specify RSpec output format (OperaHelperFormatter,',
53
+ 'SpartanFormatter, Specdoc) and optionally an output',
54
+ 'file') do |t|
55
+ options.format = t
56
+ end
57
+
58
+ opts.on('-e', '--executable=EXECUTABLE', 'Browser to run the test with. ',
59
+ 'Will override environmental variable OPERA_PATH') do |e|
60
+ options.executable = e
61
+ end
62
+
63
+ opts.on('-o', '--options=OPTIONS', 'Options passed to the optional executable. ',
64
+ 'Will override environmental variable OPERA_ARGS') do |o|
65
+ options.options = o
66
+ end
67
+
68
+ opts.separator ''
69
+ opts.separator 'Common options:'
70
+
71
+ opts.on_tail('-h', '--help', 'Show this message') do
72
+ abort opts
73
+ end
74
+
75
+ opts.on_tail('-v', '--version', 'Show version') do
76
+ abort "OperaWatir version #{OperaWatir.version}"
77
+ end
78
+ end
79
+
80
+ opts.parse!(args)
81
+ options
82
+ end
83
+
84
+ end
85
+
86
+ options = Options.parse(ARGV)
87
+
88
+ abort 'operawatir: You need to specify at least one test file to run' if ARGV.empty?
89
+ abort 'operawatir: --ng and --check-syntax is disabled for now' if options.ng or options.check_syntax
90
+
91
+ RSpec.configure do |c|
92
+ c.color_enabled = options.color
93
+ c.formatter = options.format
94
+ c.files_to_run = ARGV
95
+ c.formatter = "documentation"
96
+ end
97
+
98
+ require 'operawatir/desktop-waiter'
99
+
100
+ OperaWatir::Waiter.configure do |c|
101
+ c.path = options.executable
102
+ c.args = options.options
103
+ c.inspectr = options.inspectr
104
+ end
105
+
106
+ OperaWatir::Waiter.run!
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env jruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+ require 'rspec'
5
+ require 'rbconfig'
6
+ require 'operawatir'
7
+ require 'operawatir/helper'
8
+
9
+ @options = {
10
+ :ng => false,
11
+ :color_enabled => Config::CONFIG['host_os'] =~ /mswin|mingw|bccwin|wince|emx/ ? false : true,
12
+ :check_syntax => false,
13
+ :formatter => 'progress'
14
+ }
15
+
16
+ # TODO
17
+ # Should steal https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/option_parser.rb
18
+
19
+ begin
20
+ OptionParser.new do |opts|
21
+ opts.banner = <<EOS
22
+ Usage: operawatir [-l|--launcher=BINARY] [-e|--executable=BINARY] [-a|--args=ARGUMENTS]
23
+ [--no-color] [-f|--format=FORMAT] [-o|--out=FILE] [-h|--help] [-v|--version] FILES
24
+ EOS
25
+
26
+ opts.separator ""
27
+ opts.separator "Specific options:"
28
+
29
+ opts.on('-l', '--launcher=BINARY', 'Path to launcher binary, will use environmental ',
30
+ 'variable OPERA_LAUNCHER if not specified') do |c|
31
+ @options[:launcher] = c
32
+ end
33
+
34
+ opts.on('-e', '--executable=BINARY', 'Browser to run the test with, will use environmental ',
35
+ 'variable OPERA_PATH if not specified') do |e|
36
+ @options[:path] = e
37
+ end
38
+
39
+ opts.on('-a', '--args=ARGUMENTS', 'Arguments passed to the executable. ',
40
+ 'Will override environmental variable OPERA_ARGS') do |a|
41
+ @options[:args] = a
42
+ end
43
+
44
+ opts.on('--no-color', 'Disable colorized output') do |c|
45
+ @options[:color_enabled] = false
46
+ end
47
+
48
+ #opts.on('-c', '--check-syntax', 'Check syntax only') do |c|
49
+ # @options[:check_syntax] = true
50
+ #end
51
+
52
+ #opts.on('--ng', 'Connect to Nailgun server instead of starting out ',
53
+ # 'own JVM') do |ng|
54
+ # @options[:ng] = ng
55
+ #end
56
+
57
+ opts.on('-f', '--format=FORMAT',
58
+ 'Specify RSpec output formatter (documentation, html, ',
59
+ 'progress (default), textmate)') do |formatter|
60
+ @options[:formatter] = formatter
61
+ end
62
+
63
+ opts.on('-o', '--out=FILE', 'Send output to a file instead of STDOUT') do |o|
64
+ @options[:output_stream] = File.open(o, 'w') or
65
+ abort "operawatir: Unable to write to file `#{o}'"
66
+ end
67
+
68
+ opts.separator ''
69
+ opts.separator 'Common options:'
70
+
71
+ opts.on_tail('-h', '--help', 'Show this message') do
72
+ abort opts
73
+ end
74
+
75
+ opts.on_tail('-v', '--version', 'Show version') do
76
+ abort "OperaWatir version #{OperaWatir.version}"
77
+ end
78
+ end.parse!(ARGV)
79
+ rescue OptionParser::InvalidOption => e
80
+ abort "operawatir: Unknown option `#{e.to_s.sub(/invalid option:\s+/, '')}'"
81
+ end
82
+
83
+ if ARGV.empty?
84
+ abort 'operawatir: You need to specify at least one test file to run'
85
+ else
86
+ @options[:files_to_run] = ARGV
87
+ end
88
+
89
+ #abort 'operawatir: --ng and --check-syntax are disabled for now' if @options[:ng] || @options[:check_syntax]
90
+
91
+ # TODO Be smarter about figuring out the Opera/Launcher path
92
+ warn 'operawatir: Launch path is not specified.' if !ENV['OPERA_LAUNCHER'] && !@options[:launcher]
93
+ warn 'operawatir: Browser path is not specified.' if !ENV['OPERA_PATH'] && !@options[:path]
94
+
95
+ OperaWatir::Helper.run! @options