operawatir 0.4-jruby → 0.4.1-jruby
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +3 -3
- data/AUTHORS +1 -0
- data/CHANGES +454 -0
- data/README.md +67 -50
- data/Rakefile +6 -10
- data/VERSION +1 -1
- data/bin/desktopwatir +52 -29
- data/bin/operawatir +50 -18
- data/lib/operadriver/client-combined-nodeps.jar +0 -0
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir.rb +8 -1
- data/lib/operawatir/browser.rb +35 -15
- data/lib/operawatir/collection.rb +2 -2
- data/lib/operawatir/compat.rb +3 -2
- data/lib/operawatir/compat/browser.rb +0 -5
- data/lib/operawatir/compat/collection.rb +15 -0
- data/lib/operawatir/compat/element.rb +72 -21
- data/lib/operawatir/compat/element_finders.rb +6 -0
- data/lib/operawatir/compat/selector.rb +7 -0
- data/lib/operawatir/compat/window.rb +49 -0
- data/lib/operawatir/desktop_browser.rb +88 -14
- data/lib/operawatir/desktop_common.rb +0 -2
- data/lib/operawatir/desktop_container.rb +82 -29
- data/lib/operawatir/desktop_helper.rb +2 -0
- data/lib/operawatir/element.rb +49 -25
- data/lib/operawatir/helper.rb +5 -3
- data/lib/operawatir/keys.rb +19 -6
- data/lib/operawatir/preferences.rb +315 -78
- data/lib/operawatir/quickwidgets.rb +2 -1
- data/lib/operawatir/quickwidgets/quick_addressfield.rb +12 -0
- data/lib/operawatir/quickwidgets/quick_button.rb +8 -2
- data/lib/operawatir/quickwidgets/quick_checkbox.rb +5 -5
- data/lib/operawatir/quickwidgets/quick_editfield.rb +8 -5
- data/lib/operawatir/quickwidgets/quick_find.rb +11 -0
- data/lib/operawatir/quickwidgets/quick_griditem.rb +11 -0
- data/lib/operawatir/quickwidgets/quick_gridlayout.rb +11 -0
- data/lib/operawatir/quickwidgets/quick_searchfield.rb +7 -1
- data/lib/operawatir/quickwidgets/quick_tab.rb +0 -1
- data/lib/operawatir/quickwidgets/quick_treeitem.rb +22 -1
- data/lib/operawatir/quickwidgets/quick_widget.rb +62 -23
- data/lib/operawatir/quickwidgets/quick_window.rb +32 -2
- data/lib/operawatir/screenshot.rb +46 -0
- data/lib/operawatir/version.rb +6 -4
- data/lib/operawatir/window.rb +53 -67
- data/operawatir.gemspec +310 -245
- data/spec/operawatir/README.md +4 -0
- data/spec/operawatir/core/browser_spec.rb +82 -0
- data/spec/operawatir/core/element_spec.rb +88 -0
- data/spec/operawatir/core/preferences_spec.rb +438 -0
- data/spec/operawatir/core/screenshot_spec.rb +76 -0
- data/spec/{new_watirspec → operawatir/core}/spatnav_spec.rb +3 -3
- data/spec/operawatir/core/window_spec.rb +76 -0
- data/spec/operawatir/desktop/desktopbrowser_spec.rb +316 -0
- data/spec/operawatir/desktop/quickaddressfield_spec.rb +59 -0
- data/spec/operawatir/desktop/quickbutton_spec.rb +248 -0
- data/spec/operawatir/desktop/quickcheckbox_spec.rb +36 -0
- data/spec/operawatir/desktop/quickdialogtab_spec.rb +30 -0
- data/spec/operawatir/desktop/quickdropdown_spec.rb +39 -0
- data/spec/operawatir/desktop/quickeditfield_spec.rb +51 -0
- data/spec/operawatir/desktop/quickfind_spec.rb +30 -0
- data/spec/operawatir/desktop/quickgriditem_spec.rb +16 -0
- data/spec/operawatir/desktop/quickgridlayout_spec.rb +15 -0
- data/spec/operawatir/desktop/quicklabel_spec.rb +28 -0
- data/spec/operawatir/desktop/quickradiobutton_spec.rb +24 -0
- data/spec/operawatir/desktop/quicksearchfield_spec.rb +26 -0
- data/spec/operawatir/desktop/quicktab_spec.rb +86 -0
- data/spec/operawatir/desktop/quickthumbnail_spec.rb +37 -0
- data/spec/operawatir/desktop/quicktreeitem_spec.rb +135 -0
- data/spec/operawatir/desktop/quicktreeview_spec.rb +30 -0
- data/spec/operawatir/desktop/quickwidget_spec.rb +101 -0
- data/spec/operawatir/desktop/quickwindow_spec.rb +108 -0
- data/spec/operawatir/desktop/shared/shared.rb +138 -0
- data/spec/operawatir/fixtures/boxes.html +22 -0
- data/spec/operawatir/fixtures/browsers.svg +367 -0
- data/spec/operawatir/fixtures/frames.html +13 -0
- data/spec/operawatir/fixtures/grid.html +29 -0
- data/spec/operawatir/fixtures/input_fields_value.html +6 -0
- data/spec/operawatir/fixtures/onclick.html +20 -0
- data/spec/operawatir/fixtures/paragraphs.html +15 -0
- data/spec/operawatir/fixtures/two_input_fields.html +6 -0
- data/spec/{new_watirspec → operawatir}/guards.rb +0 -0
- data/spec/operawatir/matchers.rb +68 -0
- data/spec/{legacy_watirspec → operawatir}/server.rb +0 -0
- data/spec/operawatir/watirspec.rake +43 -0
- data/spec/operawatir/watirspec_desktophelper.rb +14 -0
- data/spec/operawatir/watirspec_helper.rb +62 -0
- data/spec/{legacy_watirspec → watir2}/area_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/areas_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/browser_spec.rb +2 -0
- data/spec/{legacy_watirspec → watir2}/button_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/buttons_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/checkbox_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/checkboxes_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/collections_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/dd_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/dds_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/del_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/dels_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/div_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/divs_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/dl_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/dls_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/dt_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/dts_spec.rb +0 -0
- data/spec/watir2/element_spec.rb +155 -0
- data/spec/{legacy_watirspec → watir2}/em_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/ems_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/filefield_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/filefields_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/2000_spans.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/bug_duplicate_attributes.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/bug_javascript_001.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/buttons_with_duplicate_ids.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/collections.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/definition_lists.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/euc-jp_text.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/forms_with_input_elements.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/frame_1.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/frame_2.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/frames.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/iframes.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/1.gif +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/2.gif +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/3.gif +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/button.jpg +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/circle.jpg +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/map.gif +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/map2.gif +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/minus.gif +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/originaltriangle.jpg +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/plus.gif +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/square.jpg +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/images/triangle.jpg +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/iso-2022-jp_text.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/javascript/helpers.js +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/jquery.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/latin1_text.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/multiple_ids.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/non_control_elements.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/parser_bug_001.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/prevent_form_submit.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/right_click.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/shift_jis_text.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/tables.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/timeout.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/timeout_window_location.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/tiny_mce.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/utf8_text.html +0 -0
- data/spec/{legacy_watirspec → watir2}/fixtures/watirspec.css +0 -0
- data/spec/{legacy_watirspec → watir2}/form_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/forms_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/frame_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/frames_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/guards.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/hidden_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/hiddens_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/hn_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/hns_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/image_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/images_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/ins_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/inses_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/label_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/labels_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/li_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/link_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/links_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/lis_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/map_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/maps_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/meta_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/metas_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/ol_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/ols_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/option_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/p_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/pre_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/pres_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/ps_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/radio_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/radios_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/select_list_spec.rb +84 -71
- data/spec/{legacy_watirspec → watir2}/select_lists_spec.rb +0 -0
- data/spec/{new_watirspec → watir2}/server.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/span_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/spans_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/spec_helper.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/strong_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/strongs_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_bodies_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_body_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_cell_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_cells_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_footer_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_footers_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_header_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_headers_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_row_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_rows_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/table_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/tables_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/text_field_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/text_fields_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/ul_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/uls_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/watir_compatibility_spec.rb +0 -0
- data/spec/{legacy_watirspec → watir2}/watirspec_helper.rb +0 -0
- data/spec/{new_watirspec → watir3}/browser_spec.rb +11 -21
- data/spec/{new_watirspec → watir3}/clipboard_spec.rb +2 -2
- data/spec/{new_watirspec → watir3}/collection_spec.rb +0 -0
- data/spec/{new_watirspec → watir3}/element_spec.rb +30 -12
- data/spec/watir3/guards.rb +39 -0
- data/spec/{new_watirspec → watir3}/keys_spec.rb +0 -0
- data/spec/watir3/server.rb +91 -0
- data/spec/{new_watirspec → watir3}/watirspec_helper.rb +0 -0
- data/spec/{new_watirspec → watir3}/window_spec.rb +8 -83
- metadata +315 -280
- data/lib/operadriver/selenium-common.jar +0 -0
- data/spec/legacy_watirspec/element_spec.rb +0 -86
- data/spec/new_watirspec/preferences_spec.rb +0 -144
- data/spec/new_watirspec/screenshot_spec.rb +0 -34
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Readme
|
2
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 [
|
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 [Watir 2](https://github.com/jarib/watirspec) and the [Watir 3](https://github.com/operasoftware/watir3-spec) specifications.
|
4
4
|
|
5
5
|
* __License:__ [New BSD](https://github.com/operasoftware/operawatir/blob/master/LICENSE)
|
6
6
|
* __Project Home:__ [http://www.opera.com/developer/tools/operawatir/](http://www.opera.com/developer/tools/operawatir/)
|
@@ -9,31 +9,11 @@
|
|
9
9
|
* __Issues:__ [https://github.com/operasoftware/operawatir/issues](https://github.com/operasoftware/operawatir/issues)
|
10
10
|
* __Gem:__ [https://rubygems.org/operawatir](http://rubygems.org/gems/operawatir)
|
11
11
|
|
12
|
-
## Third-Party Libraries
|
13
|
-
|
14
|
-
OperaWatir uses the following libraries:
|
15
|
-
|
16
|
-
- [OperaDriver](http://www.opera.com/developer/tools/operadriver/) (Apache 2.0 License)
|
17
|
-
- [rspec](https://github.com/rspec/rspec) (MIT License)
|
18
|
-
- [jeweler](https://github.com/technicalpickles/jeweler) (MIT License)
|
19
|
-
- [rake](https://github.com/jimweirich/rake) (MIT License)
|
20
|
-
- [yard](https://github.com/lsegal/yard) (MIT License)
|
21
|
-
- [mongrel](http://rubyforge.org/projects/mongrel) (Ruby License)
|
22
|
-
- [sinatra](http://www.sinatrarb.com/) (MIT License)
|
23
|
-
- [rr](http://rubyforge.org/projects/double-ruby) (MIT License)
|
24
|
-
- [bluecloth](http://deveiate.org/projects/BlueCloth) (BSD License)
|
25
|
-
- [inifile](https://github.com/TwP/inifile) (MIT License)
|
26
|
-
- [clipboard](https://github.com/janlelis/clipboard) (MIT License)
|
27
|
-
- [activesupport](http://rubyonrails.org/) (MIT License)
|
28
|
-
- [i18n](https://github.com/svenfuchs/i18n) (MIT License)
|
29
|
-
- [deprecated](https://github.com/erikh/deprecated) (BSD License)
|
30
|
-
- [bundler](http://gembundler.com/) (MIT License)
|
31
|
-
|
32
12
|
## Install
|
33
13
|
|
34
14
|
### Requirements
|
35
15
|
|
36
|
-
OperaWatir runs on GNU/Linux, Mac OS X and Windows operating systems. Required dependencies are _Java_ >= 1.6.0, _JRuby_
|
16
|
+
OperaWatir runs on GNU/Linux, Mac OS X and Windows operating systems. Required dependencies are _Java_ >= 1.6.0, _JRuby_ <= 1.5.5, _RubyGems_ >= 1.3.5, _RSpec_ >= 2.4, and a somewhat recent build of Opera (desktop, internal, mobile). For Windows you must also have the Microsoft Visual C++ 2008 Redistributable Package.
|
37
17
|
|
38
18
|
### Installation procedure
|
39
19
|
|
@@ -45,16 +25,6 @@ To install (leave out the “sudo” command if you're installing on Windows):
|
|
45
25
|
|
46
26
|
Next, make sure that JRuby's ``bin`` directory is a part of your ``PATH`` environmental variable on GNU/Linux.
|
47
27
|
|
48
|
-
## Limitations
|
49
|
-
|
50
|
-
__Before you get started playing with OperaWatir, there are a few important things you need to keep in mind.__
|
51
|
-
|
52
|
-
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.
|
53
|
-
|
54
|
-
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.
|
55
|
-
|
56
|
-
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.
|
57
|
-
|
58
28
|
## Examples
|
59
29
|
|
60
30
|
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.
|
@@ -67,8 +37,8 @@ Let's take a closer look at how this works.
|
|
67
37
|
browser = OperaWatir::Browser.new
|
68
38
|
|
69
39
|
browser.goto 'http://en.wikipedia.org/'
|
70
|
-
browser.text_field(:id
|
71
|
-
browser.button(:id
|
40
|
+
browser.text_field(:id, 'searchInput').set 'Opera'
|
41
|
+
browser.button(:id, 'searchButton').click
|
72
42
|
|
73
43
|
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.
|
74
44
|
|
@@ -84,10 +54,9 @@ As Watir scripts are run in a full-featured browser, all keypresses and clicks w
|
|
84
54
|
browser = OperaWatir::Browser.new
|
85
55
|
|
86
56
|
browser.goto 'http://en.wikipedia.org/'
|
87
|
-
browser.text_field(:id
|
57
|
+
browser.text_field(:id, 'searchInput').click
|
88
58
|
browser.type 'Hello world'
|
89
|
-
browser.
|
90
|
-
browser.key 'Enter'
|
59
|
+
browser.keys.send :down, :enter
|
91
60
|
|
92
61
|
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:
|
93
62
|
|
@@ -96,12 +65,12 @@ The first suggested link will be selected by pressing arrow down (``'Down'``) an
|
|
96
65
|
|
97
66
|
browser.goto 'http://www.phoboslab.org/biolab/'
|
98
67
|
sleep 2
|
99
|
-
browser.
|
68
|
+
browser.keys.send 'X'
|
100
69
|
sleep 1
|
101
|
-
browser.
|
102
|
-
5.times { browser.
|
103
|
-
2.times { browser.
|
104
|
-
browser.
|
70
|
+
browser.keys.down :right
|
71
|
+
5.times { browser.keys.send 'X' }
|
72
|
+
2.times { browser.keys.send 'C' }
|
73
|
+
browser.keys.up :right
|
105
74
|
|
106
75
|
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.
|
107
76
|
|
@@ -111,9 +80,9 @@ Sending commands to the browser is great, but sometimes we want to get something
|
|
111
80
|
browser = OperaWatir::Browser.new
|
112
81
|
|
113
82
|
browser.goto 'http://gulesider.no/'
|
114
|
-
browser.text_field(:name
|
115
|
-
browser.button(:name
|
116
|
-
puts browser.li(:class
|
83
|
+
browser.text_field(:name, 'search_word').set 'Opera Software'
|
84
|
+
browser.button(:name, 'btn_cs').click
|
85
|
+
puts browser.li(:class, 'tel').text
|
117
86
|
|
118
87
|
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.
|
119
88
|
|
@@ -125,15 +94,15 @@ When writing test suites you can use the OperaWatir::Helper class to help ease s
|
|
125
94
|
end
|
126
95
|
|
127
96
|
it 'finds the phone number to Opera Software' do
|
128
|
-
browser.text_field(:name
|
129
|
-
browser.button(:name
|
97
|
+
browser.text_field(:name, 'search_word').set 'Opera Software'
|
98
|
+
browser.button(:name, 'btn_cs').click
|
130
99
|
browser.li(:class => 'tel').text.should == '24 16 40 00'
|
131
100
|
end
|
132
101
|
|
133
102
|
it 'finds the phone number to the Norwegian Opera and Ballet' do
|
134
|
-
browser.text_field(:name
|
135
|
-
browser.button(:name
|
136
|
-
browser.li(:class
|
103
|
+
browser.text_field(:name, 'search_word').set 'Den Norske Opera'
|
104
|
+
browser.button(:name, 'btn_cs').click
|
105
|
+
browser.li(:class, 'tel').text.should == '21 42 21 00'
|
137
106
|
end
|
138
107
|
end
|
139
108
|
|
@@ -149,3 +118,51 @@ Each block of code corresponds to a single named test case returning PASS or FAI
|
|
149
118
|
2 examples, 0 failures
|
150
119
|
|
151
120
|
If anything fails, more information about each failure will be provided.
|
121
|
+
|
122
|
+
You can also see ``operawatir -h`` for more usage information:
|
123
|
+
|
124
|
+
Usage: operawatir [-m|--manual] [-l|--launcher=BINARY] [--binary=BINARY]
|
125
|
+
[-a|--args=ARGUMENTS] [-q|--no-quit] [--opera-idle] [-b|--backtrace]
|
126
|
+
[--no-color] [-t|--tag=TAG] [-f|--format=FORMAT] [-o|--out=FILE]
|
127
|
+
[-h|--help] [-v|--version] FILES
|
128
|
+
|
129
|
+
Specific options:
|
130
|
+
-m, --manual Wait for a manual connection from opera:debug
|
131
|
+
-l, --launcher=BINARY Path to launcher binary, will use environmental
|
132
|
+
variable OPERA_LAUNCHER if not specified
|
133
|
+
--binary=BINARY Browser to run the test with, will use guess the
|
134
|
+
path or use environmental variable OPERA_PATH if
|
135
|
+
not specified
|
136
|
+
-a, --args=ARGUMENTS Arguments passed to the binary, will override
|
137
|
+
environmental variable OPERA_ARGS
|
138
|
+
-q, --no-quit Disable quitting of Opera at the end of a test run
|
139
|
+
--opera-idle Enable OperaIdle
|
140
|
+
-b, --backtrace Enable full backtrace
|
141
|
+
--no-color Disable colorized output
|
142
|
+
-t, --tag=TAG Specify tags to only run examples with the specified
|
143
|
+
tag, to exclude examples, add ~ before the tag (e.g.
|
144
|
+
`~slow')
|
145
|
+
-o, --out=FILE Send output to a file instead of STDOUT
|
146
|
+
-f, --format=FORMAT Specify RSpec output formatter (documentation,
|
147
|
+
html, progress (default), textmate)
|
148
|
+
|
149
|
+
Common options:
|
150
|
+
-h, --help Show this message
|
151
|
+
-v, --version Show version
|
152
|
+
|
153
|
+
## Third-Party Libraries
|
154
|
+
|
155
|
+
OperaWatir uses the following libraries:
|
156
|
+
|
157
|
+
- [OperaDriver](http://www.opera.com/developer/tools/operadriver/) (Apache 2.0 License)
|
158
|
+
- [rspec](https://github.com/rspec/rspec) (MIT License)
|
159
|
+
- [jeweler](https://github.com/technicalpickles/jeweler) (MIT License)
|
160
|
+
- [rake](https://github.com/jimweirich/rake) (MIT License)
|
161
|
+
- [yard](https://github.com/lsegal/yard) (MIT License)
|
162
|
+
- [mongrel](http://rubyforge.org/projects/mongrel) (Ruby License)
|
163
|
+
- [sinatra](http://www.sinatrarb.com/) (MIT License)
|
164
|
+
- [rr](http://rubyforge.org/projects/double-ruby) (MIT License)
|
165
|
+
- [bluecloth](http://deveiate.org/projects/BlueCloth) (BSD License)
|
166
|
+
- [clipboard](https://github.com/janlelis/clipboard) (MIT License)
|
167
|
+
- [deprecated](https://github.com/erikh/deprecated) (BSD License)
|
168
|
+
- [bundler](http://gembundler.com/) (MIT License)
|
data/Rakefile
CHANGED
@@ -17,24 +17,20 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.summary = 'Toolkit for automating interactions with the Opera web browser.'
|
18
18
|
gem.description = <<-EOF
|
19
19
|
OperaWatir is a part of the Watir (pronounced water) family of
|
20
|
-
free software Ruby libraries for automating web
|
21
|
-
|
22
|
-
|
23
|
-
browser. It aims for full compliancy with the
|
24
|
-
|
20
|
+
free software Ruby libraries for automating web browsers.
|
21
|
+
OperaWatir provides a querying engine and Ruby bindings for a
|
22
|
+
backend Java library, OperaDriver, for driving the Opera web
|
23
|
+
browser. It aims for full compliancy with the Watir 2 and Watir 3
|
24
|
+
specifications.
|
25
25
|
EOF
|
26
26
|
|
27
27
|
gem.rubyforge_project = gem.name
|
28
28
|
|
29
29
|
gem.platform = 'jruby'
|
30
|
-
gem.required_ruby_version = '>= 1.8.7'
|
31
30
|
gem.has_rdoc = true
|
32
31
|
gem.extra_rdoc_files = ['README.md']
|
33
32
|
|
34
|
-
gem.add_dependency 'rspec', '
|
35
|
-
gem.add_dependency 'inifile', '>= 0.3'
|
36
|
-
gem.add_dependency 'i18n'
|
37
|
-
gem.add_dependency 'activesupport', '>= 3.0.1'
|
33
|
+
gem.add_dependency 'rspec', '>= 2.4'
|
38
34
|
gem.add_dependency 'deprecated'
|
39
35
|
|
40
36
|
gem.add_development_dependency 'jeweler'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4
|
1
|
+
0.4.1
|
data/bin/desktopwatir
CHANGED
@@ -4,15 +4,19 @@ require 'optparse'
|
|
4
4
|
require 'rspec'
|
5
5
|
require 'rbconfig'
|
6
6
|
require 'operawatir'
|
7
|
-
|
7
|
+
|
8
8
|
|
9
9
|
@options = {
|
10
|
-
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
10
|
+
#:manual => false,
|
11
|
+
:ng => false,
|
12
|
+
:color_enabled => true,
|
13
|
+
:check_syntax => false,
|
14
|
+
:output_stream => IO.new(1, 'w'),
|
15
|
+
:format => 'progress',
|
16
|
+
:no_quit => false,
|
17
|
+
:no_restart => false,
|
18
|
+
:opera_idle => false,
|
19
|
+
#:full_backtrace => false # TODO: Provide fix for RSpec
|
16
20
|
}
|
17
21
|
|
18
22
|
# TODO
|
@@ -21,13 +25,21 @@ require 'operawatir/desktop_helper'
|
|
21
25
|
begin
|
22
26
|
OptionParser.new do |opts|
|
23
27
|
opts.banner = <<EOS
|
24
|
-
|
25
|
-
|
28
|
+
|
29
|
+
Usage: desktopwatir [-l|--launcher=BINARY] [-e|--executable=BINARY]
|
30
|
+
[-a|--args=ARGUMENTS] [--no-color] [-q|--no-quit] [-r|--no-restart]
|
31
|
+
[--opera-idle] [-b|--backtrace] [-t|--tag=TAG] [-f|--format=FORMAT]
|
32
|
+
[-o|--out=FILE] [-h|--help] [-v|--version] FILES
|
26
33
|
EOS
|
27
34
|
|
28
|
-
opts.separator
|
29
|
-
opts.separator
|
35
|
+
opts.separator ''
|
36
|
+
opts.separator 'Specific options:'
|
30
37
|
|
38
|
+
#run without launcher and with manual connection, restart not possible (same as -rq)
|
39
|
+
#opts.on('-m', '--manual', 'Wait for a manual connection from opera:debug') do |c|
|
40
|
+
# @options[:manual] = c
|
41
|
+
#end
|
42
|
+
|
31
43
|
opts.on('-l', '--launcher=BINARY', 'Path to launcher binary, will use environmental ',
|
32
44
|
'variable OPERA_LAUNCHER if not specified') do |c|
|
33
45
|
@options[:launcher] = c
|
@@ -46,35 +58,41 @@ EOS
|
|
46
58
|
opts.on('--no-color', 'Disable colorized output') do |c|
|
47
59
|
@options[:color_enabled] = false
|
48
60
|
end
|
49
|
-
|
61
|
+
|
50
62
|
opts.on('-q', '--no-quit', 'Disable quitting of Opera at the end of a testrun') do |c|
|
51
63
|
@options[:no_quit] = true
|
52
64
|
end
|
53
65
|
|
54
|
-
|
66
|
+
opts.on('-r', '--no-restart', 'Disables automatic relaunching of Opera') do |c|
|
55
67
|
@options[:no_restart] = true
|
56
68
|
end
|
57
69
|
|
58
|
-
|
59
|
-
|
60
|
-
|
70
|
+
opts.on('--opera-idle', 'Enable OperaIdle') do |c|
|
71
|
+
@options[:opera_idle] = true
|
72
|
+
end
|
61
73
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
74
|
+
opts.on('-b', '--backtrace', 'Enable full backtrace') do |c|
|
75
|
+
@options[:full_backtrace] = true
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on('-o', '--out=FILE', 'Send output to a file instead of STDOUT') do |o|
|
79
|
+
@options[:output_stream] = File.open(o, 'w') or
|
80
|
+
abort "desktopwatir: Unable to write to file `#{o}'"
|
81
|
+
end
|
66
82
|
|
67
83
|
opts.on('-f', '--format=FORMAT',
|
68
84
|
'Specify RSpec output formatter (documentation, html, ',
|
69
85
|
'progress (default), textmate)') do |formatter|
|
70
86
|
@options[:formatter] = formatter
|
71
87
|
end
|
72
|
-
|
73
|
-
opts.on('-
|
74
|
-
|
75
|
-
|
88
|
+
|
89
|
+
opts.on('-t', '--tag=TAG',
|
90
|
+
'Specify tags to only run examples with the specified tag
|
91
|
+
To exclude examples, add ~ before the tag (e.g. ~slow)
|
92
|
+
(TAG is always converted to a symbol)') do |tag|
|
93
|
+
@options[:filter_run] = tag
|
76
94
|
end
|
77
|
-
|
95
|
+
|
78
96
|
opts.separator ''
|
79
97
|
opts.separator 'Common options:'
|
80
98
|
|
@@ -93,10 +111,15 @@ end
|
|
93
111
|
if ARGV.empty?
|
94
112
|
abort 'desktopwatir: You need to specify at least one test file to run'
|
95
113
|
else
|
96
|
-
@options[:
|
97
|
-
@options[:
|
114
|
+
@options[:files_or_directories_to_run] = ARGV
|
115
|
+
@options[:files_or_directories_to_run].map! do | f |
|
116
|
+
if f.include? "\\"
|
117
|
+
f
|
118
|
+
else
|
119
|
+
Dir.glob(f)
|
120
|
+
end
|
121
|
+
end.flatten!
|
98
122
|
end
|
99
123
|
|
100
|
-
|
101
|
-
|
124
|
+
require 'operawatir/desktop_helper'
|
102
125
|
OperaWatir::DesktopHelper.run! @options
|
data/bin/operawatir
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
#!/usr/bin/env jruby
|
2
2
|
require 'rubygems'
|
3
3
|
require 'optparse'
|
4
|
+
require 'stringio'
|
4
5
|
require 'rspec'
|
5
6
|
require 'rbconfig'
|
6
7
|
require 'operawatir'
|
7
|
-
require 'operawatir/helper'
|
8
8
|
|
9
9
|
@options = {
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
10
|
+
:manual => false,
|
11
|
+
:ng => false,
|
12
|
+
:color_enabled => true,
|
13
|
+
:check_syntax => false,
|
14
|
+
:output_stream => IO.new(1, 'w'),
|
15
|
+
:format => 'progress',
|
16
|
+
:no_quit => false,
|
17
|
+
:opera_idle => false,
|
18
|
+
#:full_backtrace => false # TODO: Provide fix for RSpec
|
14
19
|
}
|
15
20
|
|
16
21
|
# TODO
|
@@ -19,36 +24,56 @@ require 'operawatir/helper'
|
|
19
24
|
begin
|
20
25
|
OptionParser.new do |opts|
|
21
26
|
opts.banner = <<EOS
|
22
|
-
Usage: operawatir [-
|
23
|
-
[
|
27
|
+
Usage: operawatir [-m|--manual] [-l|--launcher=BINARY] [--binary=BINARY]
|
28
|
+
[-a|--args=ARGUMENTS] [-q|--no-quit] [--opera-idle] [-b|--backtrace]
|
29
|
+
[--no-color] [-t|--tag=TAG] [-f|--format=FORMAT] [-o|--out=FILE]
|
30
|
+
[-h|--help] [-v|--version] FILES
|
24
31
|
EOS
|
25
32
|
|
26
|
-
opts.separator
|
27
|
-
opts.separator
|
33
|
+
opts.separator ''
|
34
|
+
opts.separator 'Specific options:'
|
35
|
+
|
36
|
+
opts.on('-m', '--manual', 'Wait for a manual connection from opera:debug') do |c|
|
37
|
+
@options[:manual] = c
|
38
|
+
end
|
28
39
|
|
29
40
|
opts.on('-l', '--launcher=BINARY', 'Path to launcher binary, will use environmental ',
|
30
41
|
'variable OPERA_LAUNCHER if not specified') do |c|
|
31
42
|
@options[:launcher] = c
|
32
43
|
end
|
33
44
|
|
34
|
-
opts.on('
|
35
|
-
'variable OPERA_PATH if
|
45
|
+
opts.on('--binary=BINARY', 'Browser to run the test with, will use guess the ',
|
46
|
+
'path or use environmental variable OPERA_PATH if ',
|
47
|
+
'not specified') do |e|
|
36
48
|
@options[:path] = e
|
37
49
|
end
|
38
50
|
|
39
|
-
opts.on('-a', '--args=ARGUMENTS', 'Arguments passed to the
|
40
|
-
'
|
51
|
+
opts.on('-a', '--args=ARGUMENTS', 'Arguments passed to the binary, will override ',
|
52
|
+
'environmental variable OPERA_ARGS') do |a|
|
41
53
|
@options[:args] = a
|
42
54
|
end
|
43
55
|
|
56
|
+
opts.on('-q', '--no-quit', 'Disable quitting of Opera at the end of a test run') do |c|
|
57
|
+
@options[:no_quit] = true
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on('--opera-idle', 'Enable OperaIdle') do |c|
|
61
|
+
@options[:opera_idle] = true
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on('-b', '--backtrace', 'Enable full backtrace') do |c|
|
65
|
+
@options[:full_backtrace] = true
|
66
|
+
end
|
67
|
+
|
44
68
|
opts.on('--no-color', 'Disable colorized output') do |c|
|
45
69
|
@options[:color_enabled] = false
|
46
70
|
end
|
47
71
|
|
48
|
-
opts.on('-
|
49
|
-
'Specify
|
50
|
-
'
|
51
|
-
|
72
|
+
opts.on('-t', '--tag=TAG',
|
73
|
+
'Specify tags to only run examples with the specified',
|
74
|
+
'tag, to exclude examples, add ~ before the tag (e.g.',
|
75
|
+
"`~slow')") do |tag|
|
76
|
+
@options[:filter_run] = tag
|
52
77
|
end
|
53
78
|
|
54
79
|
opts.on('-o', '--out=FILE', 'Send output to a file instead of STDOUT') do |o|
|
@@ -56,6 +81,12 @@ EOS
|
|
56
81
|
abort "operawatir: Unable to write to file `#{o}'"
|
57
82
|
end
|
58
83
|
|
84
|
+
opts.on('-f', '--format=FORMAT',
|
85
|
+
'Specify RSpec output formatter (documentation, ',
|
86
|
+
'html, progress (default), textmate)') do |formatter|
|
87
|
+
@options[:formatter] = formatter
|
88
|
+
end
|
89
|
+
|
59
90
|
opts.separator ''
|
60
91
|
opts.separator 'Common options:'
|
61
92
|
|
@@ -74,7 +105,8 @@ end
|
|
74
105
|
if ARGV.empty?
|
75
106
|
abort 'operawatir: You need to specify at least one test file to run'
|
76
107
|
else
|
77
|
-
@options[:
|
108
|
+
@options[:files_or_directories_to_run] = ARGV
|
78
109
|
end
|
79
110
|
|
111
|
+
require 'operawatir/helper'
|
80
112
|
OperaWatir::Helper.run! @options
|