operawatir 0.4-jruby → 0.4.1-jruby
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.expand_path('../../watirspec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe 'Browser' do
|
4
|
+
|
5
|
+
# Note: This method is deprecated, but still needs to be tested.
|
6
|
+
describe '#opera_action' do
|
7
|
+
it 'executes the specified action' do
|
8
|
+
browser.url = fixture('input_fields_value.html')
|
9
|
+
window.find_by_id('one').click
|
10
|
+
browser.opera_action('Select all')
|
11
|
+
window.eval_js('one = document.getElementById("one");')
|
12
|
+
window.eval_js('one.value.substr(one.selectionStart, one.selectionEnd - one.selectionStart)').to_s.should == 'foobar'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Note: This method is deprecated, but still needs to be tested.
|
17
|
+
describe '#opera_action_list' do
|
18
|
+
it 'returns a list of available Opera actions' do
|
19
|
+
browser.url = 'about:blank'
|
20
|
+
browser.opera_action_list.should include 'Copy'
|
21
|
+
browser.opera_action_list.should include 'Paste'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Note: This method is deprecated, but still needs to be tested.
|
26
|
+
describe '#key' do
|
27
|
+
it 'presses the specified key' do
|
28
|
+
browser.url = fixture('two_input_fields.html')
|
29
|
+
window.find_by_name('one').click
|
30
|
+
browser.key 'a'
|
31
|
+
window.find_by_name('one').value.should == 'a'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Note: This method is deprecated, but still needs to be tested.
|
36
|
+
describe '#key_down' do
|
37
|
+
it 'holds down the specfied key' do
|
38
|
+
browser.url = fixture('grid.html')
|
39
|
+
browser.key_down 'Shift' # This invokes spatnav on desktop browsers
|
40
|
+
browser.key 'Down'
|
41
|
+
browser.key 'Down'
|
42
|
+
browser.key_up 'Shift'
|
43
|
+
window.execute_script("document.activeElement.text;").to_s.should == 'C2'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Note: This method is deprecated, but still needs to be tested.
|
48
|
+
describe '#key_up' do
|
49
|
+
it 'releases the specfied key' do
|
50
|
+
browser.url = fixture('grid.html')
|
51
|
+
browser.key_down 'Shift' # This invokes spatnav on desktop browsers
|
52
|
+
browser.key 'Down'
|
53
|
+
browser.key 'Down'
|
54
|
+
browser.key_up 'Shift'
|
55
|
+
browser.key 'Down'
|
56
|
+
window.execute_script("document.activeElement.text;").to_s.should == 'C2'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Note: This method is deprecated, but still needs to be tested.
|
61
|
+
describe '#type' do
|
62
|
+
it 'types a string of characters' do
|
63
|
+
browser.url = fixture('two_input_fields.html')
|
64
|
+
window.find_by_name('one').click
|
65
|
+
browser.type 'foobar'
|
66
|
+
window.find_by_name('one').value.should == 'foobar'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#desktop?' do
|
71
|
+
it 'returns true or false' do
|
72
|
+
[true,false].should include browser.desktop?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#version' do
|
77
|
+
it 'fetches the version number of the driver' do
|
78
|
+
browser.version.should match /\d{1,}\.\d{1,}\.\d{1,}/
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.expand_path('../../watirspec_helper', __FILE__)
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
describe 'Element' do
|
5
|
+
|
6
|
+
describe '#triple_click' do
|
7
|
+
it 'clicks three times' do
|
8
|
+
browser.url = fixture('onclick.html')
|
9
|
+
window.find_by_tag('button').triple_click
|
10
|
+
window.find_by_id('clicks').text.should == '3'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#quadruple_click' do
|
15
|
+
it 'clicks four times' do
|
16
|
+
browser.url = fixture('onclick.html')
|
17
|
+
window.find_by_tag('button').quadruple_click
|
18
|
+
window.find_by_id('clicks').text.should == '4'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# This method is deprecated, but needs to be tested anyway.
|
23
|
+
describe '#compare_hash' do
|
24
|
+
|
25
|
+
before :each do
|
26
|
+
browser.url = fixture('boxes.html')
|
27
|
+
@one = window.find_by_id('one');
|
28
|
+
@two = window.find_by_id('two');
|
29
|
+
@three = window.find_by_id('three');
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'interprets two visually different elements as different' do
|
33
|
+
@one.compare_hash(@two).should be_false
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'interprets two visually identical elements as identical' do
|
37
|
+
@one.compare_hash(@three).should be_true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#screenshot' do
|
42
|
+
after (:each) do
|
43
|
+
File.delete(Dir.tmpdir + '/screenshot.png')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'takes a screenshot of the specified element' do
|
47
|
+
browser.url = fixture('boxes.html')
|
48
|
+
window.find_by_id('one').screenshot(Dir.tmpdir + '/screenshot.png', 1000).should be_true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#visual_hash' do
|
53
|
+
|
54
|
+
before :each do
|
55
|
+
browser.url = fixture('boxes.html')
|
56
|
+
@one = window.find_by_id('one');
|
57
|
+
@two = window.find_by_id('two');
|
58
|
+
@three = window.find_by_id('three');
|
59
|
+
@four = window.find_by_id('four');
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns a hash' do
|
63
|
+
@one.visual_hash.should =~ /^(0x)[a-f0-9]{32}$/
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns identical hashes for visually identical elements' do
|
67
|
+
@one.visual_hash.should == @three.visual_hash
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns different hashes for visually different elements' do
|
71
|
+
@one.visual_hash.should_not == @two.visual_hash
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns correct hashes when querying several elements in sequence' do
|
75
|
+
@one.visual_hash.should == @three.visual_hash
|
76
|
+
@two.visual_hash.should == @four.visual_hash
|
77
|
+
@one.visual_hash.should_not == @two.visual_hash
|
78
|
+
@two.visual_hash.should_not == @three.visual_hash
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'returns a hash of an SVG element' do
|
82
|
+
browser.url = fixture('browsers.svg')
|
83
|
+
window.find_by_tag('svg').visual_hash.should =~ /^(0x)[a-f0-9]{32}$/
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,438 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path('../../watirspec_helper', __FILE__)
|
3
|
+
|
4
|
+
describe 'Preferences' do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
@prefs = browser.preferences
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#new' do
|
11
|
+
it 'constructs a new instance' do
|
12
|
+
@prefs.should exist
|
13
|
+
@prefs.should be_kind_of OperaWatir::Preferences
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#each' do
|
18
|
+
it 'contains a list of entries' do
|
19
|
+
@prefs.each do |p|
|
20
|
+
p.should be_kind_of OperaWatir::Preferences::Entry
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#length' do
|
26
|
+
it 'has a valid length' do
|
27
|
+
@prefs.length.should be_kind_of Integer
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'has several sections' do
|
31
|
+
@prefs.length.should > 10
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'responds to alias #size' do
|
35
|
+
@prefs.size.should == @prefs.length
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#first' do
|
40
|
+
it 'is a valid entry' do
|
41
|
+
@prefs.first.should be_kind_of OperaWatir::Preferences::Entry
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'is a section' do
|
45
|
+
@prefs.first.should be_section
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'has a key' do
|
49
|
+
@prefs.first.key.should_not be_empty
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has a method' do
|
53
|
+
@prefs.first.method.should match /^([a-z_]+)/
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#last' do
|
58
|
+
it 'is a valid entry' do
|
59
|
+
@prefs.last.should be_kind_of OperaWatir::Preferences::Entry
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'is a section' do
|
63
|
+
@prefs.last.should be_section
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'has a key' do
|
67
|
+
@prefs.last.key.should_not be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'has a method' do
|
71
|
+
@prefs.last.method.should match /^([a-z_]+)/
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#empty?' do
|
76
|
+
it 'returns a valid type' do
|
77
|
+
@prefs.empty?.should be_kind_of FalseClass
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'is not empty' do
|
81
|
+
@prefs.should_not be_empty
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#to_s' do
|
86
|
+
before :all do
|
87
|
+
@string = @prefs.to_s
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'returns a string' do
|
91
|
+
@string.should be_kind_of String
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'contains sections' do
|
95
|
+
@string.should match /^([a-z_]+)/
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'contains keys' do
|
99
|
+
@string.should match /^\s{2}([a-z_]+)/
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'contains values' do
|
103
|
+
@string.should match /^\s{4}value:.+\"(.+)\"/
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'contains defaults' do
|
107
|
+
@string.should match /^\s{4}default:.+\"(.+)\"/
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#to_a' do
|
112
|
+
before :all do
|
113
|
+
@array = @prefs.to_a
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'returns an array' do
|
117
|
+
@array.should be_kind_of Array
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'returns entries of the type Preference::Entry' do
|
121
|
+
@array[0].should be_kind_of OperaWatir::Preferences::Entry
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'has several entries' do
|
125
|
+
@array.size > 10
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'contains keys' do
|
129
|
+
@array[0].key.should_not be_empty
|
130
|
+
@array[0].method.should match /([a-z_]+)/
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe 'Section' do # Preferences::Entry / Preferences#method_missing
|
135
|
+
|
136
|
+
before :all do
|
137
|
+
@section = @prefs.link
|
138
|
+
end
|
139
|
+
|
140
|
+
describe '#new' do
|
141
|
+
it 'constructs a new instance' do
|
142
|
+
@section.should exist
|
143
|
+
@section.should be_kind_of OperaWatir::Preferences::Entry
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe '#parent' do
|
148
|
+
it 'contains the parent class' do
|
149
|
+
@section.parent.should be_kind_of OperaWatir::Preferences
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#method' do
|
154
|
+
it 'has a valid method name' do
|
155
|
+
@section.method.should match /([a-z_]+)/
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe '#key' do
|
160
|
+
it 'has a key name' do
|
161
|
+
@section.key.should_not be_empty
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe '#value' do
|
166
|
+
it 'raises exception' do
|
167
|
+
lambda { @section.value }.should raise_error OperaWatir::Exceptions::PreferencesException
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe '#value=' do
|
172
|
+
it 'raises exception' do
|
173
|
+
lambda { @section.value = 'hoobaflooba' }.should raise_error OperaWatir::Exceptions::PreferencesException
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe '#default' do
|
178
|
+
it 'raises exception' do
|
179
|
+
lambda { @section.default }.should raise_error OperaWatir::Exceptions::PreferencesException
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#default!' do
|
184
|
+
it 'raises exception' do
|
185
|
+
lambda { @section.default! }.should raise_error OperaWatir::Exceptions::PreferencesException
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe '#section?' do
|
190
|
+
it 'returns a valid type' do
|
191
|
+
@section.section?.should be_kind_of TrueClass
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'is a section' do
|
195
|
+
@section.section?.should be_true
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#exists?' do
|
200
|
+
it 'returns a valid type' do
|
201
|
+
@section.exists?.should be_kind_of TrueClass
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'exists' do
|
205
|
+
@section.exists?.should be_true
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'responds to alias #exist?' do
|
209
|
+
@section.exist?.should == @section.exists?
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe '#each' do
|
214
|
+
it 'contains a list of entries' do
|
215
|
+
@section.each do |k|
|
216
|
+
k.should be_kind_of OperaWatir::Preferences::Entry
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe '#length' do
|
222
|
+
it 'has a valid length' do
|
223
|
+
@section.length.should be_kind_of Integer
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'has one or more keys' do
|
227
|
+
@section.length.should >= 1
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'responds alias #size' do
|
231
|
+
@section.size.should == @section.length
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe '#first' do
|
236
|
+
it 'is a valid entry' do
|
237
|
+
@section.first.should be_kind_of OperaWatir::Preferences::Entry
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'has a key' do
|
241
|
+
@section.first.key.should_not be_empty
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'has a key which is not a section' do
|
245
|
+
@section.first.should_not be_section
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'has a key with a method' do
|
249
|
+
@section.first.method.should match /^([a-z_]+)/
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
describe '#last' do
|
254
|
+
it 'is a valid entry' do
|
255
|
+
@section.last.should be_kind_of OperaWatir::Preferences::Entry
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'has a key' do
|
259
|
+
@section.last.key.should_not be_empty
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'is a key which is not section' do
|
263
|
+
@section.last.should_not be_section
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'has a key with a method' do
|
267
|
+
@section.last.method.should match /^([a-z_]+)/
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe '#empty?' do
|
272
|
+
it 'returns a valid type' do
|
273
|
+
@section.empty?.should be_kind_of FalseClass
|
274
|
+
end
|
275
|
+
|
276
|
+
it 'is not empty' do
|
277
|
+
@section.should_not be_empty
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe 'Keys' do # Preferences::Entry / Entry#method_missing
|
282
|
+
|
283
|
+
before :all do
|
284
|
+
@key = @section.expiry
|
285
|
+
end
|
286
|
+
|
287
|
+
describe '#parent' do
|
288
|
+
it 'contains the parent class' do
|
289
|
+
@key.parent.should be_kind_of OperaWatir::Preferences::Entry
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe '#method' do
|
294
|
+
it 'has a valid method name' do
|
295
|
+
@key.method.should match /([a-z_]+)/
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
describe '#key' do
|
300
|
+
it 'has a key name' do
|
301
|
+
@section.key.should_not be_empty
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
describe '#type' do # TODO
|
306
|
+
|
307
|
+
# Note that the types aren't proper Ruby objects, but strings.
|
308
|
+
|
309
|
+
it '`expiry` is a type integer' do
|
310
|
+
@key.type.should include 'Integer'
|
311
|
+
end
|
312
|
+
|
313
|
+
it '`color` is a type boolean' do
|
314
|
+
@section.color.type.should include 'Boolean'
|
315
|
+
end
|
316
|
+
|
317
|
+
it '`opera_account.server_address` is a type string' do
|
318
|
+
@prefs.opera_account.server_address.type.should include 'String'
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
describe '#value' do
|
323
|
+
it 'returns a valid type' do
|
324
|
+
@key.value.should be_kind_of String
|
325
|
+
end
|
326
|
+
|
327
|
+
it 'is not empty' do
|
328
|
+
@key.value.should_not be_empty
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
describe '#value=' do
|
333
|
+
it 'is changed when set on a string preference' do
|
334
|
+
@key.value = '20'
|
335
|
+
@key.value.should == '20'
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'is changed when set on an integer preference' do
|
339
|
+
@section.color.value = true
|
340
|
+
@section.color.value.should be_true
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'has effect in the browser when changed' do
|
344
|
+
@section.strikethrough.value = '1' #true
|
345
|
+
window.url = fixture('../simple.html')
|
346
|
+
window.a.execute_script('this.currentStyle.textDecoration').should include /strike\-through/
|
347
|
+
end
|
348
|
+
|
349
|
+
# JRUBY-1127 makes it impossible to unwrap Java exceptions in JRuby.
|
350
|
+
|
351
|
+
# it 'does not allow setting an invalid value' do
|
352
|
+
# lambda { @section.color.value = 'foo' }.should raise_error NativeException
|
353
|
+
# end
|
354
|
+
|
355
|
+
after :each do
|
356
|
+
@key.default!
|
357
|
+
@section.color.default!
|
358
|
+
@section.strikethrough.default!
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
describe '#default' do
|
363
|
+
it 'returns the default value' do
|
364
|
+
@key.default.should == '10'
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
describe '#default!' do
|
369
|
+
before :each do
|
370
|
+
@key.value = '1337'
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'returns and sets default value' do
|
374
|
+
@key.default!.should == @key.default
|
375
|
+
@key.value.should == @key.default
|
376
|
+
end
|
377
|
+
|
378
|
+
after :all do
|
379
|
+
@key.default!
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
describe '#section?' do
|
384
|
+
it 'returns a valid type' do
|
385
|
+
@key.section?.should be_kind_of FalseClass
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'is not a section' do
|
389
|
+
@key.section?.should be_false
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
describe '#each' do
|
394
|
+
it 'raises error' do
|
395
|
+
lambda { @key.each { |e| } }.should raise_error OperaWatir::Exceptions::PreferencesException
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
describe '#length' do
|
400
|
+
it 'raises error' do
|
401
|
+
lambda { @key.length }.should raise_error OperaWatir::Exceptions::PreferencesException
|
402
|
+
end
|
403
|
+
|
404
|
+
it 'responds to alias #size' do
|
405
|
+
lambda { @key.size }.should raise_error OperaWatir::Exceptions::PreferencesException
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
describe '#first' do
|
410
|
+
it 'raises error' do
|
411
|
+
lambda { @key.first }.should raise_error OperaWatir::Exceptions::PreferencesException
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
describe '#last' do
|
416
|
+
it 'raises error' do
|
417
|
+
lambda { @key.last }.should raise_error OperaWatir::Exceptions::PreferencesException
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
describe '#empty?' do
|
422
|
+
it 'raises error' do
|
423
|
+
lambda { @key.empty? }.should raise_error OperaWatir::Exceptions::PreferencesException
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
end
|
428
|
+
|
429
|
+
end
|
430
|
+
|
431
|
+
describe '#cleanup' do; end # TODO
|
432
|
+
describe '#cleanup!' do; end # TODO
|
433
|
+
|
434
|
+
after :all do
|
435
|
+
@prefs.cleanup!
|
436
|
+
end
|
437
|
+
|
438
|
+
end
|