operawatir 0.3.2-jruby → 0.3.7.pre1-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 -0
- data/.yardopts +0 -3
- data/Gemfile +5 -6
- data/Rakefile +7 -2
- data/VERSION +1 -1
- data/bin/desktopwatir +86 -93
- data/bin/operawatir +3 -18
- data/lib/operadriver/commons-io-2.0.1.jar +0 -0
- data/lib/operadriver/selenium-common.jar +0 -0
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir/browser.rb +93 -77
- data/lib/operawatir/compat/browser.rb +5 -0
- data/lib/operawatir/compat/element.rb +10 -17
- data/lib/operawatir/compat.rb +0 -1
- data/lib/operawatir/desktop-waiter.rb +1 -143
- data/lib/operawatir/desktop_browser.rb +80 -33
- data/lib/operawatir/desktop_enums.rb +3 -3
- data/lib/operawatir/desktop_helper.rb +84 -0
- data/lib/operawatir/element.rb +23 -4
- data/lib/operawatir/exceptions.rb +3 -0
- data/lib/operawatir/helper.rb +4 -1
- data/lib/operawatir/platform.rb +0 -38
- data/lib/operawatir/preferences.rb +164 -0
- data/lib/operawatir/quickwidgets/quick_addressfield.rb +14 -0
- data/lib/operawatir/quickwidgets/quick_button.rb +7 -1
- data/lib/operawatir/quickwidgets/quick_checkbox.rb +5 -4
- data/lib/operawatir/quickwidgets/quick_dialogtab.rb +1 -1
- data/lib/operawatir/quickwidgets/quick_editfield.rb +9 -4
- data/lib/operawatir/quickwidgets/quick_thumbnail.rb +1 -1
- data/lib/operawatir/quickwidgets/quick_treeitem.rb +2 -2
- data/lib/operawatir/quickwidgets/quick_treeview.rb +2 -1
- data/lib/operawatir/quickwidgets/quick_widget.rb +51 -21
- data/lib/operawatir/quickwidgets/quick_window.rb +34 -19
- data/lib/operawatir/spatnav.rb +38 -0
- data/lib/operawatir/window.rb +76 -12
- data/lib/operawatir.rb +20 -4
- data/operawatir.gemspec +48 -28
- data/spec/new_watirspec/browser_spec.rb +5 -84
- data/spec/new_watirspec/clipboard_spec.rb +41 -56
- data/spec/new_watirspec/collection_spec.rb +2 -2
- data/spec/new_watirspec/element_spec.rb +8 -8
- data/spec/new_watirspec/keys_spec.rb +8 -10
- data/spec/new_watirspec/preferences_spec.rb +144 -0
- data/spec/new_watirspec/screenshot_spec.rb +34 -0
- data/spec/new_watirspec/spatnav_spec.rb +62 -0
- data/utils/formatters/operahelper_formatter.rb +50 -0
- data/utils/formatters/spartan_formatter.rb +29 -0
- metadata +126 -61
- data/lib/operawatir/compat/deprecation.rb +0 -46
- data/utils/launchers/launcher-linux-i686 +0 -0
- data/utils/launchers/launcher-linux-x86_64 +0 -0
- data/utils/launchers/launcher-mac +0 -0
- data/utils/launchers/launcher-win32-i86pc.exe +0 -0
data/.gitmodules
ADDED
data/.yardopts
CHANGED
data/Gemfile
CHANGED
@@ -2,12 +2,11 @@ source :rubygems
|
|
2
2
|
|
3
3
|
group :development do
|
4
4
|
gem "bundler", "~> 1.0.0"
|
5
|
-
gem "jeweler"
|
6
|
-
gem "rcov", ">= 0"
|
7
|
-
gem "yard", ">= 0.6.3"
|
5
|
+
gem "jeweler"
|
8
6
|
gem "bluecloth", "= 1.0.1"
|
9
|
-
gem "
|
10
|
-
gem "sinatra", ">= 1.0.0"
|
7
|
+
gem "yard"
|
11
8
|
gem "mongrel", ">= 1.1.5"
|
12
|
-
gem "
|
9
|
+
gem "sinatra", ">= 1.1"
|
10
|
+
gem "rr"
|
11
|
+
gem "clipboard"
|
13
12
|
end
|
data/Rakefile
CHANGED
@@ -31,17 +31,22 @@ EOF
|
|
31
31
|
gem.has_rdoc = true
|
32
32
|
gem.extra_rdoc_files = ['README.md']
|
33
33
|
|
34
|
-
gem.add_dependency 'rspec', '
|
34
|
+
gem.add_dependency 'rspec', '= 2.4'
|
35
|
+
gem.add_dependency 'inifile', '>= 0.3'
|
36
|
+
gem.add_dependency 'i18n'
|
37
|
+
gem.add_dependency 'activesupport', '>= 3.0.1'
|
38
|
+
gem.add_dependency 'deprecated'
|
35
39
|
|
36
40
|
gem.add_development_dependency 'jeweler'
|
37
41
|
gem.add_development_dependency 'rake'
|
42
|
+
gem.add_development_dependency 'bluecloth', '= 1.0.1'
|
38
43
|
gem.add_development_dependency 'yard'
|
39
44
|
gem.add_development_dependency 'mongrel', '>= 1.1.5'
|
40
45
|
gem.add_development_dependency 'sinatra', '>= 1.1'
|
41
46
|
gem.add_development_dependency 'rr'
|
47
|
+
gem.add_development_dependency 'clipboard'
|
42
48
|
|
43
49
|
gem.files.exclude '.gitignore'
|
44
|
-
gem.files.exclude '.gitmodules'
|
45
50
|
end
|
46
51
|
|
47
52
|
CLEAN.add 'pkg'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7.pre1
|
data/bin/desktopwatir
CHANGED
@@ -1,109 +1,102 @@
|
|
1
1
|
#!/usr/bin/env jruby
|
2
|
-
|
3
2
|
require 'rubygems'
|
4
|
-
|
5
3
|
require 'optparse'
|
6
|
-
require 'ostruct'
|
7
|
-
require 'rbconfig'
|
8
4
|
require 'rspec'
|
5
|
+
require 'rbconfig'
|
9
6
|
require 'operawatir'
|
7
|
+
require 'operawatir/desktop_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
|
+
:format => 'progress',
|
14
|
+
:no_quit => false,
|
15
|
+
:no_restart => false
|
16
|
+
}
|
17
|
+
|
18
|
+
# TODO
|
19
|
+
# Should steal https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/option_parser.rb
|
20
|
+
|
21
|
+
begin
|
22
|
+
OptionParser.new do |opts|
|
23
|
+
opts.banner = <<EOS
|
24
|
+
Usage: desktopwatir [-l|--launcher=BINARY] [-e|--executable=BINARY] [-a|--args=ARGUMENTS]
|
25
|
+
[--no-color] [-q|--no-quit] [-r|--no-restart] [-f|--format=FORMAT] [-o|--out=FILE] [-h|--help] [-v|--version] FILES
|
26
|
+
EOS
|
27
|
+
|
28
|
+
opts.separator ""
|
29
|
+
opts.separator "Specific options:"
|
30
|
+
|
31
|
+
opts.on('-l', '--launcher=BINARY', 'Path to launcher binary, will use environmental ',
|
32
|
+
'variable OPERA_LAUNCHER if not specified') do |c|
|
33
|
+
@options[:launcher] = c
|
34
|
+
end
|
10
35
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
class Options
|
15
|
-
|
16
|
-
def self.parse(args)
|
17
|
-
options = OpenStruct.new
|
18
|
-
|
19
|
-
options.ng = false
|
20
|
-
options.inspectr = ENV['OPERA_INSPECTR'] || ''
|
21
|
-
options.color = Config::CONFIG['host_os'] =~ /mswin|msys|mingw32/ ? false : true
|
22
|
-
options.check_syntax = false
|
23
|
-
options.format = 'progress'
|
24
|
-
options.executable = ENV['OPERA_PATH'] || ''
|
25
|
-
options.options = ENV['OPERA_ARGS'] || ''
|
26
|
-
|
27
|
-
opts = OptionParser.new do |opts|
|
28
|
-
opts.banner = "Usage: operawatir [--ng] [-i|--inspectr] [--color] [-c|--check-syntax]\n" +
|
29
|
-
" [-f|--format=FORMAT[:OUT_FILE]] [-e|--executable=BINARY] [-o|--options=OPTIONS]\n" +
|
30
|
-
" [-h|--help] [-v|--version] FILES"
|
31
|
-
|
32
|
-
opts.separator ""
|
33
|
-
opts.separator "Specific options:"
|
34
|
-
|
35
|
-
opts.on('--ng', 'Connect to Nailgun server instead of starting our ',
|
36
|
-
'own JVM') do |ng|
|
37
|
-
options.ng = ng
|
38
|
-
end
|
39
|
-
|
40
|
-
opts.on('-i', '--inspectr', 'Attach inspectr to browser instance') do |i|
|
41
|
-
options.inspectr = i
|
42
|
-
end
|
43
|
-
|
44
|
-
opts.on('--color', 'Enable colorized output (default: enabled)') do |c|
|
45
|
-
options.color = c
|
46
|
-
end
|
47
|
-
|
48
|
-
opts.on('-c', '--check-syntax', 'Check syntax only') do |c|
|
49
|
-
options.check_syntax = c
|
50
|
-
end
|
51
|
-
|
52
|
-
opts.on('-f', '--format=FORMAT[:OUT_FILE]',
|
53
|
-
[:OperaHelperFormatter, :SpartanFormatter, :progress,
|
54
|
-
:documentation],
|
55
|
-
'Specify RSpec output format (OperaHelperFormatter,',
|
56
|
-
'SpartanFormatter, Specdoc) and optionally an output',
|
57
|
-
'file') do |t|
|
58
|
-
options.format = t
|
59
|
-
end
|
60
|
-
|
61
|
-
opts.on('-e', '--executable=EXECUTABLE', 'Browser to run the test with. ',
|
62
|
-
'Will override environmental variable OPERA_PATH') do |e|
|
63
|
-
options.executable = e
|
64
|
-
end
|
65
|
-
|
66
|
-
opts.on('-o', '--options=OPTIONS', 'Options passed to the optional executable. ',
|
67
|
-
'Will override environmental variable OPERA_ARGS') do |o|
|
68
|
-
options.options = o
|
69
|
-
end
|
70
|
-
|
71
|
-
opts.separator ''
|
72
|
-
opts.separator 'Common options:'
|
73
|
-
|
74
|
-
opts.on_tail('-h', '--help', 'Show this message') do
|
75
|
-
abort opts
|
76
|
-
end
|
77
|
-
|
78
|
-
opts.on_tail('-v', '--version', 'Show version') do
|
79
|
-
abort "OperaWatir version #{OperaWatir.version}"
|
80
|
-
end
|
36
|
+
opts.on('-e', '--executable=BINARY', 'Browser to run the test with, will use environmental ',
|
37
|
+
'variable OPERA_PATH if not specified') do |e|
|
38
|
+
@options[:path] = e
|
81
39
|
end
|
82
40
|
|
83
|
-
opts.
|
84
|
-
|
85
|
-
|
41
|
+
opts.on('-a', '--args=ARGUMENTS', 'Arguments passed to the executable. ',
|
42
|
+
'Will override environmental variable OPERA_ARGS') do |a|
|
43
|
+
@options[:args] = a
|
44
|
+
end
|
86
45
|
|
87
|
-
|
46
|
+
opts.on('--no-color', 'Disable colorized output') do |c|
|
47
|
+
@options[:color_enabled] = false
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on('-q', '--no-quit', 'Disable quitting of Opera at the end of a testrun') do |c|
|
51
|
+
@options[:no_quit] = true
|
52
|
+
end
|
88
53
|
|
89
|
-
|
54
|
+
opts.on('-r', '--no-restart', 'Disables automatic relaunching of Opera') do |c|
|
55
|
+
@options[:no_restart] = true
|
56
|
+
end
|
90
57
|
|
91
|
-
|
92
|
-
|
58
|
+
#opts.on('-c', '--check-syntax', 'Check syntax only') do |c|
|
59
|
+
# @options[:check_syntax] = true
|
60
|
+
#end
|
61
|
+
|
62
|
+
#opts.on('--ng', 'Connect to Nailgun server instead of starting out ',
|
63
|
+
# 'own JVM') do |ng|
|
64
|
+
# @options[:ng] = ng
|
65
|
+
#end
|
66
|
+
|
67
|
+
opts.on('-f', '--format=FORMAT',
|
68
|
+
'Specify RSpec output formatter (documentation, html, ',
|
69
|
+
'progress (default), textmate)') do |formatter|
|
70
|
+
@options[:formatter] = formatter
|
71
|
+
end
|
93
72
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
73
|
+
opts.on('-o', '--out=FILE', 'Send output to a file instead of STDOUT') do |o|
|
74
|
+
@options[:output_stream] = File.open(o, 'w') or
|
75
|
+
abort "desktopwatir: Unable to write to file `#{o}'"
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.separator ''
|
79
|
+
opts.separator 'Common options:'
|
100
80
|
|
101
|
-
|
81
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
82
|
+
abort opts
|
83
|
+
end
|
102
84
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
85
|
+
opts.on_tail('-v', '--version', 'Show version') do
|
86
|
+
abort "OperaWatir version #{OperaWatir.version}"
|
87
|
+
end
|
88
|
+
end.parse!(ARGV)
|
89
|
+
rescue OptionParser::InvalidOption => e
|
90
|
+
abort "desktopwatir: Unknown option `#{e.to_s.sub(/invalid option:\s+/, '')}'"
|
107
91
|
end
|
108
92
|
|
109
|
-
|
93
|
+
if ARGV.empty?
|
94
|
+
abort 'desktopwatir: You need to specify at least one test file to run'
|
95
|
+
else
|
96
|
+
@options[:files_to_run] = ARGV
|
97
|
+
@options[:files_to_run].map! { | f | Dir.glob(f) }.flatten!
|
98
|
+
end
|
99
|
+
|
100
|
+
#abort 'desktopwatir: --ng and --check-syntax are disabled for now' if @options[:ng] || @options[:check_syntax]
|
101
|
+
|
102
|
+
OperaWatir::DesktopHelper.run! @options
|
data/bin/operawatir
CHANGED
@@ -8,7 +8,7 @@ require 'operawatir/helper'
|
|
8
8
|
|
9
9
|
@options = {
|
10
10
|
:ng => false,
|
11
|
-
:color_enabled =>
|
11
|
+
:color_enabled => OperaWatir::Platform.os == :windows ? false : true,
|
12
12
|
:check_syntax => false,
|
13
13
|
:format => 'progress'
|
14
14
|
}
|
@@ -19,7 +19,7 @@ require 'operawatir/helper'
|
|
19
19
|
begin
|
20
20
|
OptionParser.new do |opts|
|
21
21
|
opts.banner = <<EOS
|
22
|
-
Usage: operawatir [-l|--launcher=BINARY] [-
|
22
|
+
Usage: operawatir [-l|--launcher=BINARY] [-b|--binary=BINARY] [-a|--args=ARGUMENTS]
|
23
23
|
[--no-color] [-f|--format=FORMAT] [-o|--out=FILE] [-h|--help] [-v|--version] FILES
|
24
24
|
EOS
|
25
25
|
|
@@ -31,7 +31,7 @@ EOS
|
|
31
31
|
@options[:launcher] = c
|
32
32
|
end
|
33
33
|
|
34
|
-
opts.on('-
|
34
|
+
opts.on('-b', '--binary=BINARY', 'Browser to run the test with, will use environmental ',
|
35
35
|
'variable OPERA_PATH if not specified') do |e|
|
36
36
|
@options[:path] = e
|
37
37
|
end
|
@@ -45,15 +45,6 @@ EOS
|
|
45
45
|
@options[:color_enabled] = false
|
46
46
|
end
|
47
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
48
|
opts.on('-f', '--format=FORMAT',
|
58
49
|
'Specify RSpec output formatter (documentation, html, ',
|
59
50
|
'progress (default), textmate)') do |formatter|
|
@@ -86,10 +77,4 @@ else
|
|
86
77
|
@options[:files_to_run] = ARGV
|
87
78
|
end
|
88
79
|
|
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
80
|
OperaWatir::Helper.run! @options
|
Binary file
|
Binary file
|
Binary file
|
data/lib/operawatir/browser.rb
CHANGED
@@ -1,57 +1,70 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
class OperaWatir::Browser
|
3
|
+
include Deprecated
|
3
4
|
|
4
|
-
attr_accessor :driver, :active_window
|
5
|
+
attr_accessor :driver, :active_window, :preferences, :keys, :spatnav
|
5
6
|
|
6
7
|
def self.settings=(settings={})
|
7
8
|
@opera_driver_settings = nil # Bust cache
|
8
|
-
@settings = settings
|
9
|
-
:path => OperaWatir::Platform.opera,
|
10
|
-
:args => OperaWatir::Platform.args
|
9
|
+
@settings = settings
|
11
10
|
end
|
12
11
|
|
13
12
|
def self.settings
|
14
13
|
@settings || self.settings = {}
|
15
14
|
end
|
16
15
|
|
16
|
+
# Constructs a new OperaDriver::Browser object.
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# browser = OperaWatir::Browser.new
|
20
|
+
#
|
21
|
+
# @return [Object] OperaWatir::Browser class.
|
17
22
|
def initialize
|
18
|
-
OperaWatir.compatibility! unless OperaWatir.api >=
|
23
|
+
OperaWatir.compatibility! unless OperaWatir.api >= 3
|
19
24
|
|
20
|
-
self.driver
|
25
|
+
self.driver = OperaDriver.new(self.class.opera_driver_settings)
|
21
26
|
self.active_window = OperaWatir::Window.new(self)
|
27
|
+
self.preferences = OperaWatir::Preferences.new(self)
|
28
|
+
self.keys = OperaWatir::Keys.new(self)
|
29
|
+
self.spatnav = OperaWatir::Spatnav.new(self)
|
22
30
|
end
|
23
31
|
|
32
|
+
alias_method :window, :active_window
|
33
|
+
|
24
34
|
# Get the name of the browser currently being run.
|
25
35
|
#
|
26
|
-
# @return [String]
|
36
|
+
# @return [String] Name of browser currently used.
|
27
37
|
def name
|
28
38
|
'Opera'
|
29
39
|
end
|
30
40
|
|
41
|
+
# Navigate to a new URL and return a Window object.
|
42
|
+
#
|
43
|
+
# @param [String] url The URL you wish to go to.
|
44
|
+
# @return [Object] A Window object.
|
31
45
|
def url=(url)
|
32
46
|
active_window.url = url
|
33
47
|
end
|
34
|
-
alias_method :url, :url=
|
35
48
|
|
36
49
|
# Tells you whether the browser object exists. Note that this is
|
37
50
|
# not the same as checking whether the object is connected to a
|
38
51
|
# browser.
|
39
52
|
#
|
40
|
-
# @return [Boolean]
|
53
|
+
# @return [Boolean] Whether Browser object exists.
|
41
54
|
def exists?
|
42
55
|
true
|
43
56
|
end
|
44
57
|
|
45
58
|
# Query to see if the browser instance is still connected.
|
46
59
|
#
|
47
|
-
# @return [Boolean]
|
48
|
-
# instance
|
60
|
+
# @return [Boolean] Whether driver is still connected to browser
|
61
|
+
# instance.
|
49
62
|
def connected?
|
50
63
|
driver.isConnected
|
51
64
|
end
|
52
65
|
|
53
66
|
# Instruct the browser instance to quit and shut down.
|
54
|
-
def quit
|
67
|
+
def quit
|
55
68
|
driver.shutdown
|
56
69
|
end
|
57
70
|
|
@@ -62,61 +75,19 @@ class OperaWatir::Browser
|
|
62
75
|
driver.closeAll
|
63
76
|
end
|
64
77
|
|
65
|
-
# Accesses the keys API in OperaWatir::Keys.
|
66
|
-
def keys
|
67
|
-
OperaWatir::Keys.new(self)
|
68
|
-
end
|
69
|
-
|
70
|
-
# Set preference pref in prefs section prefs_section to value
|
71
|
-
# specified.
|
72
|
-
#
|
73
|
-
# TODO: This needs to be moved to a separate preference section.
|
74
|
-
#
|
75
|
-
# @param [String] prefs_section The prefs section the pref belongs to
|
76
|
-
# @param [String] pref The preference to set
|
77
|
-
# @param [String] value The value to set the preference to
|
78
|
-
def set_preference(prefs_section, pref, value)
|
79
|
-
@driver.setPref(prefs_section, pref, value.to_s)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Get value of preference pref in prefs section prefs_section.
|
83
|
-
#
|
84
|
-
# TODO: This needs to be moved to a separate preference section.
|
85
|
-
#
|
86
|
-
# @param [String] prefs_section The prefs section the pref belongs to
|
87
|
-
# @param [String] pref The preference to get
|
88
|
-
#
|
89
|
-
# @return [String] The value of the preference
|
90
|
-
def get_preference(prefs_section, pref)
|
91
|
-
@driver.getPref(prefs_section, pref)
|
92
|
-
end
|
93
|
-
|
94
|
-
# Get default value of preference pref in prefs section
|
95
|
-
# prefs_section.
|
96
|
-
#
|
97
|
-
# TODO: This needs to be moved to a separate preference section.
|
98
|
-
#
|
99
|
-
# @param [String] prefs_section The prefs section the pref belongs to
|
100
|
-
# @param [String] pref The preference to get
|
101
|
-
#
|
102
|
-
# @return [String] The value of the preference
|
103
|
-
def get_default_preference(prefs_section, pref)
|
104
|
-
@driver.getDefaultPref(prefs_section, pref)
|
105
|
-
end
|
106
|
-
|
107
78
|
# Get the version number of the driver. This _is not_ the same as
|
108
79
|
# the version number for OperaWatir, which can be retrieved using
|
109
80
|
# +OperaWatir.version+ instead.
|
110
81
|
#
|
111
|
-
# @return [String]
|
82
|
+
# @return [String] Driver version.
|
112
83
|
def version
|
113
|
-
driver.
|
84
|
+
driver.getVersion
|
114
85
|
end
|
115
86
|
|
116
87
|
# Get process identifier for spawned Opera browser instance. This
|
117
88
|
# will only work if instance was started through OperaWatir.
|
118
89
|
#
|
119
|
-
# @return [Integer]
|
90
|
+
# @return [Integer] The process ID of the browser instance.
|
120
91
|
def pid
|
121
92
|
driver.getPid
|
122
93
|
end
|
@@ -124,28 +95,22 @@ class OperaWatir::Browser
|
|
124
95
|
# Get the target device's platform. This is not equivalent of the
|
125
96
|
# platform the OperaWatir server might be running on.
|
126
97
|
#
|
127
|
-
# @return [String]
|
98
|
+
# @return [String] Operating system flavour of the device we're
|
99
|
+
# testing on.
|
128
100
|
def platform
|
129
101
|
driver.getPlatform
|
130
102
|
end
|
131
103
|
|
132
|
-
# Will fetch the build number for the attached browser instance.
|
133
|
-
#
|
134
|
-
# @return [Integer] build number of attached browser instance
|
135
|
-
def build
|
136
|
-
driver.getBuild
|
137
|
-
end
|
138
|
-
|
139
104
|
# Get the full path to the attached browser binary.
|
140
105
|
#
|
141
|
-
# @return [String]
|
106
|
+
# @return [String] Path to the attached browser's binary.
|
142
107
|
def path
|
143
108
|
driver.getPath
|
144
109
|
end
|
145
110
|
|
146
111
|
# Fetches the user agent (UA) string the browser currently uses.
|
147
112
|
#
|
148
|
-
# @return [String]
|
113
|
+
# @return [String] User agent string.
|
149
114
|
def ua_string
|
150
115
|
driver.getUaString
|
151
116
|
end
|
@@ -153,19 +118,20 @@ class OperaWatir::Browser
|
|
153
118
|
# Is attached browser instance of type internal build or public
|
154
119
|
# desktop?
|
155
120
|
#
|
156
|
-
# @return [Boolean]
|
157
|
-
# false otherwise
|
121
|
+
# @return [Boolean] True if browser attached is of type desktop,
|
122
|
+
# false otherwise.
|
158
123
|
def desktop?
|
159
124
|
false # FIXME
|
160
125
|
end
|
161
126
|
|
162
127
|
# Sends an Opera action to the browser.
|
163
128
|
#
|
164
|
-
# @param
|
165
|
-
# @return [String]
|
129
|
+
# @param [String] Name of the action.
|
130
|
+
# @return [String] Optional return from the performed action.
|
166
131
|
def opera_action(name, *args)
|
167
|
-
|
132
|
+
driver.operaAction(name, param.to_java(:string))
|
168
133
|
end
|
134
|
+
deprecated :opera_action
|
169
135
|
|
170
136
|
# Full list of available Opera actions in the Opera build you're
|
171
137
|
# using. Note that this list varies from configuration to
|
@@ -173,9 +139,59 @@ class OperaWatir::Browser
|
|
173
139
|
# available to devices-type builds will vary greatly from those
|
174
140
|
# available to desktop-types.
|
175
141
|
#
|
176
|
-
# @return [String]
|
142
|
+
# @return [String] List of available Opera actions.
|
177
143
|
def opera_action_list
|
178
|
-
|
144
|
+
driver.getOperaActionList.to_s
|
145
|
+
end
|
146
|
+
deprecated :opera_action_list
|
147
|
+
|
148
|
+
# Selects all content in the currently focused element. Equivalent
|
149
|
+
# to pressing C-a in a desktop browser. To select content in a
|
150
|
+
# <textarea> or an <input> field, remember to click it first.
|
151
|
+
def select_all
|
152
|
+
|
153
|
+
# FIXME
|
154
|
+
driver.operaAction('Select all')
|
155
|
+
end
|
156
|
+
|
157
|
+
# Copies the currently selected content to the clipboard.
|
158
|
+
# Equivalent to pressing C-c in a desktop browser.
|
159
|
+
def copy
|
160
|
+
|
161
|
+
# FIXME: #copy, #cut and #paste really shouldn't use platform-
|
162
|
+
# dependent keypresses like this. But until DSK-327491 is fixed,
|
163
|
+
# this will have to do.
|
164
|
+
if OperaWatir::Platform.os == :macosx
|
165
|
+
keys.send [:command, 'c']
|
166
|
+
else
|
167
|
+
keys.send [:control, 'c']
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Cuts the currently selected content to the clipboard. Equivalent
|
172
|
+
# to pressing C-x in a desktop browser.
|
173
|
+
def cut
|
174
|
+
|
175
|
+
# FIXME
|
176
|
+
if OperaWatir::Platform.os == :macosx
|
177
|
+
keys.send [:command, 'x']
|
178
|
+
else
|
179
|
+
keys.send [:control, 'x']
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Pastes content from the clipboard into the currently focused
|
184
|
+
# element. Equivalent to pressing C-v in a desktop browser. To
|
185
|
+
# paste content into textarea or input fields, remember to click it
|
186
|
+
# first.
|
187
|
+
def paste
|
188
|
+
|
189
|
+
# FIXME
|
190
|
+
if OperaWatir::Platform.os == :macosx
|
191
|
+
keys.send [:command, 'v']
|
192
|
+
else
|
193
|
+
keys.send [:control, 'v']
|
194
|
+
end
|
179
195
|
end
|
180
196
|
|
181
197
|
private
|
@@ -183,9 +199,9 @@ private
|
|
183
199
|
def self.opera_driver_settings
|
184
200
|
@opera_driver_settings ||= OperaDriverSettings.new.tap {|s|
|
185
201
|
s.setRunOperaLauncherFromOperaDriver true
|
186
|
-
s.setOperaLauncherBinary self.settings[:launcher]
|
187
|
-
s.setOperaBinaryLocation self.settings[:path]
|
188
|
-
s.setOperaBinaryArguments self.settings[:args] + ' -watirtest'
|
202
|
+
s.setOperaLauncherBinary self.settings[:launcher] if self.settings[:launcher]
|
203
|
+
s.setOperaBinaryLocation self.settings[:path] if self.settings[:path]
|
204
|
+
s.setOperaBinaryArguments self.settings[:args].to_s + ' opera:debug' #+ ' -watirtest'
|
189
205
|
}
|
190
206
|
end
|
191
207
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module OperaWatir
|
2
2
|
module Compat
|
3
3
|
module Browser
|
4
|
+
extend Forwardable
|
4
5
|
|
5
6
|
def method_missing(method, *args, &blk)
|
6
7
|
if active_window.respond_to? method
|
@@ -15,6 +16,10 @@ module OperaWatir
|
|
15
16
|
browser.quit!
|
16
17
|
end
|
17
18
|
|
19
|
+
# Class#type is defined by Ruby, it will never reach
|
20
|
+
# #method_missing.
|
21
|
+
def_delegator :active_window, :type
|
22
|
+
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
@@ -33,19 +33,6 @@ class OperaWatir::Element
|
|
33
33
|
|
34
34
|
alias_method :to_s, :text
|
35
35
|
|
36
|
-
# On elements of type `<input>` this gets the value of the value
|
37
|
-
# attribute, on every other element type it returns the text
|
38
|
-
# content.
|
39
|
-
#
|
40
|
-
# @return [String] value of the element
|
41
|
-
def value
|
42
|
-
if tag_name == 'INPUT' or attr?(:value)
|
43
|
-
attr(:value)
|
44
|
-
else
|
45
|
-
text
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
36
|
# Checks whether the text content of the element contains the given
|
50
37
|
# string In the compatibility layer as the preferred way of doing
|
51
38
|
# this is.
|
@@ -73,13 +60,13 @@ class OperaWatir::Element
|
|
73
60
|
node.click(x.to_i, y.to_i)
|
74
61
|
end
|
75
62
|
|
63
|
+
alias_method :click_no_wait, :click_async
|
64
|
+
|
76
65
|
# Focuses the element
|
77
66
|
def focus
|
78
|
-
|
67
|
+
fire_event :focus
|
79
68
|
end
|
80
69
|
|
81
|
-
alias_method :fire_event, :trigger!
|
82
|
-
|
83
70
|
# Submits a form, or the form the elment is contained in.
|
84
71
|
def submit
|
85
72
|
assert_exists
|
@@ -101,7 +88,7 @@ class OperaWatir::Element
|
|
101
88
|
self.text = value
|
102
89
|
else
|
103
90
|
assert_enabled
|
104
|
-
|
91
|
+
click_async
|
105
92
|
end
|
106
93
|
end
|
107
94
|
|
@@ -159,6 +146,12 @@ class OperaWatir::Element
|
|
159
146
|
attr(:colspan).to_i
|
160
147
|
end
|
161
148
|
|
149
|
+
|
150
|
+
# Opera-specific
|
151
|
+
def compare_hash(other)
|
152
|
+
visual_hash == other.visual_hash
|
153
|
+
end
|
154
|
+
|
162
155
|
private
|
163
156
|
|
164
157
|
def assert_enabled!
|
data/lib/operawatir/compat.rb
CHANGED