operawatir 0.4.1.pre2-jruby → 0.4.1.pre3-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.
Files changed (37) hide show
  1. data/CHANGES +233 -0
  2. data/VERSION +1 -1
  3. data/bin/desktopwatir +36 -16
  4. data/bin/operawatir +27 -14
  5. data/lib/operadriver/webdriver-opera.jar +0 -0
  6. data/lib/operawatir/compat/browser.rb +0 -5
  7. data/lib/operawatir/compat/collection.rb +2 -0
  8. data/lib/operawatir/compat/element.rb +3 -0
  9. data/lib/operawatir/compat/element_finders.rb +4 -0
  10. data/lib/operawatir/compat/selector.rb +7 -0
  11. data/lib/operawatir/compat/window.rb +8 -0
  12. data/lib/operawatir/compat.rb +3 -2
  13. data/lib/operawatir/desktop_browser.rb +18 -6
  14. data/lib/operawatir/desktop_helper.rb +2 -0
  15. data/lib/operawatir/quickwidgets/quick_addressfield.rb +12 -0
  16. data/lib/operawatir/quickwidgets/quick_checkbox.rb +1 -1
  17. data/lib/operawatir/quickwidgets/quick_editfield.rb +7 -4
  18. data/lib/operawatir/quickwidgets/quick_searchfield.rb +2 -0
  19. data/lib/operawatir/quickwidgets/quick_widget.rb +1 -1
  20. data/lib/operawatir/quickwidgets/quick_window.rb +6 -2
  21. data/lib/operawatir/screenshot.rb +46 -0
  22. data/lib/operawatir/window.rb +19 -16
  23. data/lib/operawatir.rb +1 -0
  24. data/operawatir.gemspec +23 -2
  25. data/spec/operawatir/core/screenshot_spec.rb +76 -0
  26. data/spec/operawatir/core/window_spec.rb +1 -12
  27. data/spec/operawatir/desktop/desktopbrowser_spec.rb +300 -0
  28. data/spec/operawatir/desktop/quickaddressfield_spec.rb +47 -0
  29. data/spec/operawatir/desktop/quickbutton_spec.rb +34 -0
  30. data/spec/operawatir/desktop/quickwidget_spec.rb +60 -0
  31. data/spec/operawatir/desktop/quickwindow_spec.rb +97 -0
  32. data/spec/operawatir/desktop/shared/shared.rb +48 -0
  33. data/spec/operawatir/matchers.rb +68 -0
  34. data/spec/operawatir/watirspec_desktophelper.rb +14 -0
  35. data/spec/operawatir/watirspec_helper.rb +1 -1
  36. data/spec/watir2/element_spec.rb +90 -21
  37. metadata +24 -3
@@ -0,0 +1,97 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../../watirspec_desktophelper', __FILE__)
3
+
4
+ describe 'QuickWindow' do
5
+ let(:documentwindow) { browser.quick_window(:name, "Document Window") }
6
+ let(:browserwindow) { browser.quick_window(:name, "Browser Window") }
7
+ let(:nonexisting_window) { browser.quick_window(:name, "Doc Window") }
8
+
9
+ subject { documentwindow }
10
+
11
+ describe '#exist?' do
12
+ it 'returns true for existing window' do
13
+ browserwindow.should exist
14
+ end
15
+
16
+ it 'returns false for non-existing window' do
17
+ nonexisting_window.should_not exist
18
+ end
19
+ end
20
+
21
+ describe '#type' do
22
+ its(:type) { should == :normal }
23
+
24
+ it 'returns Dialog for Dialog' do
25
+ browser.open_dialog_with_key_press("New Preferences Dialog", "F12", :ctrl).should > 0
26
+ browser.quick_window(:name, "New Preferences Dialog").type == "Dialog"
27
+ browser.close_dialog("New Preferences Dialog")
28
+ end
29
+
30
+ it 'throws exception if unknown window' do
31
+ expect { nonexisting_window.type }.to raise_error OperaWatir::Exceptions::UnknownObjectException
32
+ end
33
+ end
34
+
35
+ describe '#name' do
36
+ its(:name) { should_not be_empty }
37
+ its(:name) { should be_kind_of String }
38
+
39
+ it 'throws exception if unknown window' do
40
+ expect { nonexisting_window.name }.to raise_error OperaWatir::Exceptions::UnknownObjectException
41
+ end
42
+ end
43
+
44
+ describe '#title' do
45
+ its(:title) { should_not be_empty }
46
+ its(:title) { should be_kind_of String }
47
+
48
+ it 'throws exception if unknown window' do
49
+ expect { nonexisting_window.title }.to raise_error OperaWatir::Exceptions::UnknownObjectException
50
+ end
51
+
52
+ end
53
+
54
+ describe '#to_s' do
55
+ it 'returns string' do
56
+ documentwindow.to_s.should_not be_empty
57
+ end
58
+ it 'returns a string' do
59
+ documentwindow.to_s.should be_kind_of String
60
+ end
61
+ it 'throws exception if unknown window' do
62
+ expect { nonexisting_window.to_s }.to raise_error OperaWatir::Exceptions::UnknownObjectException
63
+ end
64
+
65
+ end
66
+
67
+ describe '#on_screen?' do
68
+ it 'throws exception if unknown window' do
69
+ expect { nonexisting_window.on_screen? }.to raise_error OperaWatir::Exceptions::UnknownObjectException
70
+ end
71
+ end
72
+
73
+ describe '#window_id' do
74
+ its(:window_id) { should be_integer }
75
+ its(:window_id) { should_not be_zero }
76
+
77
+ it 'throws exception if unknown window' do
78
+ expect { nonexisting_window.window_id }.to raise_error OperaWatir::Exceptions::UnknownObjectException
79
+ end
80
+ end
81
+
82
+ describe '#window_info_string' do
83
+ its(:window_info_string) { should be_kind_of String }
84
+ its(:window_info_string) { should_not be_empty }
85
+
86
+ it 'throws exception if unknown window' do
87
+ expect { nonexisting_window.window_info_string }.to raise_error OperaWatir::Exceptions::UnknownObjectException
88
+ end
89
+ end
90
+
91
+ its(:driver) { should be_instance_of Java::ComOperaCoreSystems::OperaDesktopDriver }
92
+
93
+ #private
94
+ # def parent_widget
95
+ # def element(refresh = false)
96
+ # def find
97
+ end
@@ -0,0 +1,48 @@
1
+ require File.expand_path('../../../watirspec_desktophelper', __FILE__)
2
+
3
+ shared_examples_for 'an editfield' do
4
+ describe '#focus_with_click' do
5
+ it 'focuses editfield' do
6
+ widget.focus_with_click
7
+ end
8
+ end
9
+
10
+ #describe '#type_text' do
11
+ #end
12
+ #describe '#clear' do
13
+ #end
14
+ #describe '#key_press' do
15
+ #end
16
+ end
17
+
18
+ shared_examples_for 'a widget' do
19
+ describe '#exist?' do
20
+ it 'returns true for existing widget' do
21
+ widget.should exist
22
+ end
23
+ end
24
+
25
+ its(:text) { should be_kind_of String } #be_a
26
+ its(:name) { should be_kind_of String }
27
+ its(:row_info_string) { should be_kind_of String }
28
+ its(:widget_info_string) { should be_kind_of String }
29
+ its(:parent_name) { should be_kind_of String } # nil?
30
+ its(:value) { should be_integer }
31
+ its(:to_s) { should be_kind_of String }
32
+ its(:driver) { should be_instance_of Java::ComOperaCoreSystems::OperaDesktopDriver }
33
+ #its(:type) { should }
34
+
35
+ describe '#enabled?' do
36
+ it 'should return boolean' do
37
+ [true, false].should include widget.enabled?
38
+ end
39
+ end
40
+
41
+ describe '#visible?' do
42
+ it 'should return boolean' do
43
+ [true, false].should include widget.enabled?
44
+ end
45
+ end
46
+
47
+ end
48
+
@@ -0,0 +1,68 @@
1
+ RSpec::Matchers.define :close_window do
2
+ match do |actual|
3
+ actual > 0
4
+ end
5
+
6
+ failure_message_for_should do |window_id|
7
+ "expected close_window to close window, but window_id returned is not valid: #{window_id}"
8
+ end
9
+ end
10
+
11
+ RSpec::Matchers.define :close_dialog do |expected|
12
+ match do |window_id|
13
+ window_id > 0
14
+ end
15
+
16
+ failure_message_for_should do |window_id|
17
+ "expected close_dialog to close dialog, but window_id returned is not valid: #{window_id}"
18
+ end
19
+ end
20
+
21
+ RSpec::Matchers.define :open_window do
22
+ match do |actual|
23
+ actual > 0
24
+ end
25
+
26
+ failure_message_for_should do |window_id|
27
+ "expected open_window to open window, but window_id returned is not valid: #{window_id}"
28
+ end
29
+ end
30
+
31
+ RSpec::Matchers.define :open_dialog do
32
+ match do |actual|
33
+ actual > 0
34
+ end
35
+
36
+ failure_message_for_should do |window_id|
37
+ "expected open_dialog to close dialog, but window_id returned is not valid: #{window_id}"
38
+ end
39
+ end
40
+
41
+
42
+ RSpec::Matchers.define :load_window do
43
+ match do |actual|
44
+ actual > 0
45
+ end
46
+
47
+ failure_message_for_should do |window_id|
48
+ "expected load... to load in window, but window_id returned is not valid: #{window_id}"
49
+ end
50
+ end
51
+
52
+ RSpec::Matchers.define :load_page do
53
+ match do |actual|
54
+ actual > 0
55
+ end
56
+
57
+ failure_message_for_should do |window_id|
58
+ "expected load_page to load page, but window_id returned is not valid: #{window_id}"
59
+ end
60
+ end
61
+
62
+ =begin
63
+ RSpec::Matchers.define :load do |expected|
64
+ match do |actual|
65
+ expected == actual
66
+ end
67
+ end
68
+ =end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'watirspec_helper'
6
+ #require 'operawatir/desktop_helper'
7
+
8
+ module WatirSpec
9
+ module Helpers
10
+ def browser
11
+ OperaWatir::DesktopHelper.browser
12
+ end
13
+ end
14
+ end
@@ -48,7 +48,7 @@ module WatirSpec
48
48
 
49
49
  end
50
50
 
51
- include OperaWatir::Exceptions
51
+ include OperaWatir::DesktopExceptions
52
52
 
53
53
  include WatirSpec::Guard::Helpers
54
54
 
@@ -6,34 +6,101 @@ describe "Element" do
6
6
  before :each do
7
7
  browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
8
  end
9
-
9
+ =begin
10
10
  describe ".new" do
11
11
  it "finds elements matching the conditions when given a hash of :how => 'what' arguments" do
12
12
  browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
13
- #browser.text_field(:class_name => 'name', :index => 2).id.should == 'new_user_last_name'
13
+ browser.text_field(:class_name => 'name', :index => 1).id.should == 'new_user_last_name'
14
14
  end
15
15
 
16
16
  it "raises UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments (non-existing object)" do
17
- conditions = {:index => 100, :name => "foo"}
18
- lambda { browser.text_field(conditions).id }.should raise_error(UnknownObjectException, /Unable to locate TextField, using (\{:name=>"foo", :index=>100\}|\{:index=>100, :name=>"foo"\})/)
17
+ lambda { browser.text_field(:index => 100, :name => "foo").id }.should raise_error(UnknownObjectException)
18
+ end
19
+
20
+ it "raises ArgumentError if given the wrong number of arguments" do
21
+ container = mock("container").as_null_object
22
+ lambda { Element.new(container, 1,2,3,4) }.should raise_error(ArgumentError)
23
+ lambda { Element.new(container, "foo") }.should raise_error(ArgumentError)
24
+ end
25
+ end
26
+
27
+ describe "#== and #eql?" do
28
+ before { browser.goto(WatirSpec.files + "/definition_lists.html") }
29
+
30
+ it "returns true if the two elements point to the same DOM element" do
31
+ a = browser.dl(:id => "experience-list")
32
+ b = browser.dl
33
+
34
+ a.should == b
35
+ a.should eql(b)
19
36
  end
20
37
 
21
- bug "WTR-351", :watir do
22
- it "raises ArgumentError if given the wrong number of arguments" do
23
- container = mock("container").as_null_object
38
+ it "returns false if the two elements are not the same" do
39
+ a = browser.dls[0]
40
+ b = browser.dls[1]
41
+
42
+ a.should_not == b
43
+ a.should_not eql(b)
44
+ end
45
+
46
+ it "returns false if the other object is not an Element" do
47
+ browser.dl.should_not == 1
48
+ end
49
+ end
50
+
51
+ describe "data-* attributes" do
52
+ before { browser.goto("file://" + File.expand_path("html/data_attributes.html", File.dirname(__FILE__))) }
53
+
54
+ bug "http://github.com/jarib/celerity/issues#issue/27", :celerity do
55
+ it "finds elements by a data-* attribute" do
56
+ browser.p(:data_type => "ruby-library").should exist
57
+ end
24
58
 
25
- lambda { Element.new(container, 1,2,3,4) }.should raise_error(ArgumentError, "wrong number of arguments (4 for 2)")
26
- lambda { Element.new(container, "foo") }.should raise_error(ArgumentError, "wrong number of arguments (1 for 2)")
59
+ it "returns the value of a data-* attribute" do
60
+ browser.p.data_type.should == "ruby-library"
27
61
  end
28
62
  end
29
63
  end
64
+ =end
65
+ describe "finding with unknown tag name" do
66
+ it "finds an element by xpath" do
67
+ browser.element(:xpath => "//*[@for='new_user_first_name']").should exist
68
+ end
69
+
70
+ it "finds an element by arbitrary attribute" do
71
+ browser.element(:id => "new_user").should exist
72
+ end
73
+ =begin
74
+ it "finds several elements by xpath" do
75
+ browser.elements(:xpath => "//a").length.should == 1
76
+ end
77
+
78
+ it "finds finds several elements by arbitrary attribute" do
79
+ browser.elements(:name => /^new_user/).length.should == 30
80
+ end
81
+ =end
82
+ end
83
+ =begin
84
+ describe "#to_subtype" do
85
+ it "returns a more precise subtype of Element (input element)" do
86
+ el = browser.element(:xpath => "//input[@type='radio']").to_subtype
87
+ el.should be_kind_of(Watir::Radio)
88
+ end
89
+
90
+ it "returns a more precise subtype of Element" do
91
+ el = browser.element(:xpath => "//*[@id='messages']").to_subtype
92
+ el.should be_kind_of(Watir::Div)
93
+ end
94
+ end
30
95
 
31
96
  describe "#focus" do
32
- it "fires the onfocus event for the given element" do
33
- tf = browser.text_field(:id, "new_user_occupation")
34
- tf.value.should == "Developer"
35
- tf.focus
36
- browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
97
+ bug "http://code.google.com/p/selenium/issues/detail?id=157", [:webdriver, :firefox] do
98
+ it "fires the onfocus event for the given element" do
99
+ tf = browser.text_field(:id, "new_user_occupation")
100
+ tf.value.should == "Developer"
101
+ tf.focus
102
+ browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
103
+ end
37
104
  end
38
105
  end
39
106
 
@@ -46,9 +113,9 @@ describe "Element" do
46
113
  end
47
114
 
48
115
  describe "#parent" do
49
- bug "WTR-352", :watir do
116
+ bug "http://github.com/jarib/celerity/issues#issue/28", :celerity do
50
117
  it "gets the parent of this element" do
51
- browser.text_field(:id, "new_user_email").parent.should be_instance_of(Form)
118
+ browser.text_field(:id, "new_user_email").parent.should be_instance_of(FieldSet)
52
119
  end
53
120
  end
54
121
  end
@@ -62,10 +129,8 @@ describe "Element" do
62
129
  browser.text_field(:id, "new_user_interests_dolls").should_not be_visible
63
130
  end
64
131
 
65
- bug "WTR-336", :watir do
66
- it "returns false if the element has style='display: none;'" do
67
- browser.div(:id, 'changed_language').should_not be_visible
68
- end
132
+ it "returns false if the element has style='display: none;'" do
133
+ browser.div(:id, 'changed_language').should_not be_visible
69
134
  end
70
135
 
71
136
  it "returns false if the element has style='visibility: hidden;" do
@@ -81,6 +146,10 @@ describe "Element" do
81
146
  it "doesn't raise when called on nested elements" do
82
147
  browser.div(:id, 'no_such_div').link(:id, 'no_such_id').should_not exist
83
148
  end
149
+
150
+ it "raises ArgumentError error if selector hash with :xpath has multiple entries" do
151
+ lambda { browser.div(:xpath => "//div", :class => "foo").exists? }.should raise_error(ArgumentError)
152
+ end
84
153
  end
85
-
154
+ =end
86
155
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 4
8
8
  - 1
9
- - pre2
10
- version: 0.4.1.pre2
9
+ - pre3
10
+ version: 0.4.1.pre3
11
11
  platform: jruby
12
12
  authors:
13
13
  - Andreas Tolf Tolfsen
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-03-08 00:00:00 +01:00
21
+ date: 2011-03-14 00:00:00 +01:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -267,6 +267,7 @@ files:
267
267
  - .gitmodules
268
268
  - .yardopts
269
269
  - AUTHORS
270
+ - CHANGES
270
271
  - Gemfile
271
272
  - LICENSE
272
273
  - README.md
@@ -289,6 +290,7 @@ files:
289
290
  - lib/operawatir/compat/collection.rb
290
291
  - lib/operawatir/compat/element.rb
291
292
  - lib/operawatir/compat/element_finders.rb
293
+ - lib/operawatir/compat/selector.rb
292
294
  - lib/operawatir/compat/window.rb
293
295
  - lib/operawatir/desktop-waiter.rb
294
296
  - lib/operawatir/desktop_browser.rb
@@ -320,6 +322,7 @@ files:
320
322
  - lib/operawatir/quickwidgets/quick_treeview.rb
321
323
  - lib/operawatir/quickwidgets/quick_widget.rb
322
324
  - lib/operawatir/quickwidgets/quick_window.rb
325
+ - lib/operawatir/screenshot.rb
323
326
  - lib/operawatir/selector.rb
324
327
  - lib/operawatir/spatnav.rb
325
328
  - lib/operawatir/version.rb
@@ -341,8 +344,15 @@ files:
341
344
  - spec/operawatir/core/browser_spec.rb
342
345
  - spec/operawatir/core/element_spec.rb
343
346
  - spec/operawatir/core/preferences_spec.rb
347
+ - spec/operawatir/core/screenshot_spec.rb
344
348
  - spec/operawatir/core/spatnav_spec.rb
345
349
  - spec/operawatir/core/window_spec.rb
350
+ - spec/operawatir/desktop/desktopbrowser_spec.rb
351
+ - spec/operawatir/desktop/quickaddressfield_spec.rb
352
+ - spec/operawatir/desktop/quickbutton_spec.rb
353
+ - spec/operawatir/desktop/quickwidget_spec.rb
354
+ - spec/operawatir/desktop/quickwindow_spec.rb
355
+ - spec/operawatir/desktop/shared/shared.rb
346
356
  - spec/operawatir/fixtures/boxes.html
347
357
  - spec/operawatir/fixtures/grid.html
348
358
  - spec/operawatir/fixtures/input_fields_value.html
@@ -350,8 +360,10 @@ files:
350
360
  - spec/operawatir/fixtures/paragraphs.html
351
361
  - spec/operawatir/fixtures/two_input_fields.html
352
362
  - spec/operawatir/guards.rb
363
+ - spec/operawatir/matchers.rb
353
364
  - spec/operawatir/server.rb
354
365
  - spec/operawatir/watirspec.rake
366
+ - spec/operawatir/watirspec_desktophelper.rb
355
367
  - spec/operawatir/watirspec_helper.rb
356
368
  - spec/watir2/area_spec.rb
357
369
  - spec/watir2/areas_spec.rb
@@ -515,10 +527,19 @@ test_files:
515
527
  - spec/operawatir/core/browser_spec.rb
516
528
  - spec/operawatir/core/element_spec.rb
517
529
  - spec/operawatir/core/preferences_spec.rb
530
+ - spec/operawatir/core/screenshot_spec.rb
518
531
  - spec/operawatir/core/spatnav_spec.rb
519
532
  - spec/operawatir/core/window_spec.rb
533
+ - spec/operawatir/desktop/desktopbrowser_spec.rb
534
+ - spec/operawatir/desktop/quickaddressfield_spec.rb
535
+ - spec/operawatir/desktop/quickbutton_spec.rb
536
+ - spec/operawatir/desktop/quickwidget_spec.rb
537
+ - spec/operawatir/desktop/quickwindow_spec.rb
538
+ - spec/operawatir/desktop/shared/shared.rb
520
539
  - spec/operawatir/guards.rb
540
+ - spec/operawatir/matchers.rb
521
541
  - spec/operawatir/server.rb
542
+ - spec/operawatir/watirspec_desktophelper.rb
522
543
  - spec/operawatir/watirspec_helper.rb
523
544
  - spec/watir2/area_spec.rb
524
545
  - spec/watir2/areas_spec.rb