lebowski 0.3.3.pre.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,3 +1,11 @@
1
+ # lebowski 0.4.0 August 16, 2011
2
+
3
+ * Updated all foundation SC proxies to work with SC 1.5 and 1.6
4
+ * Changed the gem build process. Now using the lebowski.gemspec file. No longer use Jeweler
5
+ * Removed Selenium 1 dependency. Now uses Selenium 2
6
+ * Fixed the user-extensions.js file to allow Lebowski to work with SC 1.5 and SC 1.6
7
+ * Updated various spec files in the examples folder
8
+
1
9
  # lebowski 0.3.3.pre.0 March 13, 2011
2
10
 
3
11
  * Initial Fixes to allow Lebowski to work with IE 7/8. Updates made to user-extensions.js file
data/bin/lebowski-spec CHANGED
@@ -14,7 +14,7 @@ if ARGV.length == 0
14
14
  exit
15
15
  end
16
16
 
17
- gem 'rspec', "~> 2.1.0"
17
+ gem 'rspec', ">= 2.1.0"
18
18
  require 'rspec'
19
19
 
20
20
  gem 'lebowski'
@@ -4,21 +4,199 @@
4
4
  # Executable to start the selenium server that will automically include
5
5
  # the required extension file
6
6
  #
7
+ # To get help use the -h or --help option:
8
+ #
9
+ # lebowski-start-server -h
10
+ #
11
+
12
+ # TODO: Put this together quickly. Needs to be refactored at some point.
13
+
14
+ require 'open-uri'
15
+ require 'optparse'
7
16
 
17
+ SELENIUM_NAME = 'Selenium'
18
+ SELENIUM_VERSION = '2.3.0'
19
+ SELENIUM_JAR = "selenium-server-standalone-#{SELENIUM_VERSION}.jar"
20
+ SELENIUM_DOMAIN = 'http://selenium.googlecode.com'
21
+ SELENIUM_JAR_URL = "#{SELENIUM_DOMAIN}/files/#{SELENIUM_JAR}"
22
+ LEBOWSKI_PATH = File.join(Dir.home, ".lebowski")
23
+ SELENIUM_JAR_PATH = File.join(LEBOWSKI_PATH, SELENIUM_JAR)
24
+ ERROR_MSG_PREFIX = "Unable to run lebowski-server. "
8
25
  DEFAULT_SELENIUM_SERVER_PORT = 4444
26
+ USER_EXTENTIONS_FILE = 'user-extensions.js'
27
+ RESOURCES_DIR_PATH = File.expand_path(File.join(File.dirname(__FILE__), %w[.. resources]))
28
+ USER_EXTENTIONS_PATH = File.join(RESOURCES_DIR_PATH, USER_EXTENTIONS_FILE)
29
+
30
+ $selenium_args = []
31
+ $verbose = false
32
+ $help = false
33
+ $selenium_server_help = false
34
+ $selenium_jar = nil
35
+ $port = DEFAULT_SELENIUM_SERVER_PORT
36
+
37
+ $optparser = OptionParser.new do |o|
38
+ o.banner = <<BANNER
39
+ Usage: lebowski-start-server [options]
40
+
41
+ To pass options on to the selenium server, prefix each option with --S. If an
42
+ option requires an argument then use = to specify the argument.
43
+ Example: lebowski-start-server --Sinteractive --Stimeout=1000
9
44
 
10
- port = DEFAULT_SELENIUM_SERVER_PORT
45
+ BANNER
11
46
 
12
- ARGV.each_with_index do |arg, index|
13
- port = ARGV[index + 1] if arg == '-port' and (index + 1) < ARGV.count
47
+ o.on('-p ARG', '--port=ARG', "Specify the server port. Default is #{DEFAULT_SELENIUM_SERVER_PORT}", Integer) do |val|
48
+ $port = val
49
+ end
50
+
51
+ o.on('-s ARG', '--selenium-jar=ARG', "Specify a path to the Selenium JAR") do |val|
52
+ $selenium_jar = File.expand_path val
53
+ end
54
+
55
+ o.on('-v', '--verbose', "Turn on verbose mode") do |val|
56
+ $verbose = true
57
+ end
58
+
59
+ o.on(nil, '--selenium-help', "Show Selenium server help") do |val|
60
+ $selenium_server_help = true
61
+ end
62
+
63
+ o.on('-h', '--help', "Show help") do |val|
64
+ $help = true
65
+ end
66
+
67
+ end
68
+
69
+ def verbose(msg, newline=true)
70
+ return if not $verbose
71
+
72
+ if newline
73
+ puts msg
74
+ else
75
+ print msg
76
+ end
14
77
  end
15
78
 
16
- puts "Running Selenium Server for Lebowski"
17
- puts "Starting server on http://localhost:#{port}"
18
- puts "To quit server, press Control-C"
79
+ def error(msg)
80
+ puts "#{ERROR_MSG_PREFIX} #{msg}"
81
+ end
82
+
83
+ def setup_selenium
84
+
85
+ if not $selenium_jar.nil?
86
+ if File.directory? $selenium_jar
87
+ error "-s requires path to file"
88
+ return false
89
+ elsif File.file? $selenium_jar
90
+ verbose "Detected Selenium server at #{$selenium_jar}"
91
+ return true
92
+ else
93
+ error "Could not detect Selenium server at #{$selenium_jar}"
94
+ return false
95
+ end
96
+ end
97
+
98
+ if File.file? SELENIUM_JAR_PATH
99
+ verbose "Detected Selenium."
100
+ $selenium_jar = SELENIUM_JAR_PATH
101
+ return true
102
+ end
103
+
104
+ puts "Could not detect Selenium server. Required by Lebowski to function."
105
+ puts "Continue by downloading Selenium server? Enter 'yes' to download."
106
+ print "> "
107
+ result = STDIN.gets
108
+
109
+ if result.chomp != 'yes'
110
+ puts "Selenium server can be download from #{SELENIUM_DOMAIN}"
111
+ return false
112
+ end
113
+
114
+ verbose "Checking if #{LEBOWSKI_PATH} exists... ", false
115
+ if not Dir.exists? LEBOWSKI_PATH
116
+ verbose "Does not exist. Creating."
117
+ Dir.mkdir LEBOWSKI_PATH
118
+ else
119
+ verbose "Exists."
120
+ end
121
+
122
+ puts "Downloading Selenium server v#{SELENIUM_VERSION} from #{SELENIUM_DOMAIN}..."
19
123
 
20
- resources_dir = File.expand_path(File.join(File.dirname(__FILE__), %w[.. resources]))
21
- selenium_server = File.join(resources_dir, 'selenium-server.jar')
22
- user_extensions = File.join(resources_dir, 'user-extensions.js')
124
+ stream = nil
125
+ begin
126
+ stream = open(SELENIUM_JAR_URL)
127
+ puts "Selenium server download successfully."
128
+ rescue Exception
129
+ error "Error trying to download Selenium server"
130
+ return false
131
+ end
132
+
133
+ begin
134
+ selenium = File.new(SELENIUM_JAR_PATH, 'wb')
135
+ selenium.write stream.read
136
+ selenium.flush
137
+ selenium.close
138
+ rescue Exception
139
+ error "Error trying to create Selenium server"
140
+ return false
141
+ end
142
+
143
+ $selenium_jar = SELENIUM_JAR_PATH
144
+
145
+ return true
146
+
147
+ end
148
+
149
+ def process_options
150
+
151
+ args = []
152
+
153
+ # Pre-process command arguments
154
+ ARGV.each do |arg|
155
+ matches = arg.match(/--S(.+)($|=(.+))/)
156
+ if not matches.nil?
157
+ $selenium_args << "-" + matches[1]
158
+ if not matches[3].nil?
159
+ $selenium_args << matches[3]
160
+ end
161
+ else
162
+ args << arg
163
+ end
164
+ end
165
+
166
+ begin
167
+ $optparser.parse args
168
+ rescue Exception => e
169
+ error e.to_s
170
+ return false
171
+ end
172
+
173
+ return true
174
+
175
+ end
176
+
177
+ def run_selenium_server
178
+ $selenium_args << '-port'
179
+ $selenium_args << $port.to_s
180
+ $selenium_args << '-help' if $selenium_server_help
181
+
182
+ puts "Running Selenium Server v#{SELENIUM_VERSION} for Lebowski"
183
+ puts "Starting server on http://localhost:#{$port}"
184
+ puts "To quit server, press Control-C"
185
+
186
+ exec 'java', '-jar', $selenium_jar, '-userExtensions', USER_EXTENTIONS_PATH, *$selenium_args
187
+ end
188
+
189
+ def main
190
+
191
+ return if not process_options
192
+
193
+ if $help
194
+ puts $optparser.to_s
195
+ return
196
+ end
197
+
198
+ run_selenium_server if setup_selenium
199
+
200
+ end
23
201
 
24
- exec 'java', '-jar', selenium_server, '-userExtensions', user_extensions, *ARGV
202
+ main
@@ -57,6 +57,10 @@ module Lebowski
57
57
  return self['$SC.RootResponder.responder.keyPane', expected_type]
58
58
  end
59
59
 
60
+ def menu_pane(expected_type=nil)
61
+ return self['$SC.RootResponder.responder.menuPane', expected_type]
62
+ end
63
+
60
64
  def responding_panes()
61
65
  if @responding_panes.nil?
62
66
  @responding_panes = ObjectArray.new self, '$SC.RootResponder.responder.panes'
@@ -236,6 +240,9 @@ module Lebowski
236
240
  SAFARI = '*safari'
237
241
  FIREFOX = '*firefox'
238
242
  CHROME = '*chrome'
243
+ IEXPLORER = '*iexplore'
244
+ IEHTA = '*iehta'
245
+ GOOGLECHROME = '*googlechrome'
239
246
 
240
247
  DEFAULT_BROWSER = FIREFOX
241
248
  DEFAULT_SELENIUM_SERVER_HOST = 'localhost'
@@ -424,7 +431,9 @@ module Lebowski
424
431
  def get_application_base_url(params)
425
432
  client = get_selenium_client(params)
426
433
  return client.browser_url if (not client.nil?)
427
- return "http://#{get_app_server_host(params)}:#{get_app_server_port(params)}"
434
+ host = get_app_server_host(params)
435
+ host = "http://#{host}" if not host =~ /^http(|s):\/\//
436
+ return "#{host}:#{get_app_server_port(params)}"
428
437
  end
429
438
 
430
439
  def get_session_id(params)
@@ -448,6 +457,12 @@ module Lebowski
448
457
  return SAFARI
449
458
  when :chrome
450
459
  return CHROME
460
+ when :iexplorer
461
+ return IEXPLORER
462
+ when :iehta
463
+ return IEHTA
464
+ when :googlechrome
465
+ return GOOGLECHROME
451
466
  else
452
467
  return DEFAULT_BROWSER
453
468
  end
@@ -35,7 +35,7 @@ module Lebowski
35
35
  :mouse_offset_x => :center,
36
36
  :mouse_offset_y => :center
37
37
  }
38
- source.drag_to self, (self.width / 2).floor, row_height - 2, params
38
+ source.drag_to self, (self.width / 2).floor, row_height, params
39
39
  end
40
40
 
41
41
  def row_height()
@@ -16,13 +16,9 @@ module Lebowski
16
16
  #
17
17
  module StallSupport
18
18
 
19
- DEFAULT_STALL = 0.2
19
+ DEFAULT_STALL = 0
20
20
 
21
- DEFAULT_KEY_STALLS = {
22
- :click => 0.2,
23
- :double_click => 0.5,
24
- :select => 0.5
25
- }
21
+ DEFAULT_KEY_STALLS = {}
26
22
 
27
23
  @@adjusted_default_stall = DEFAULT_STALL
28
24
 
@@ -232,23 +232,26 @@ module Lebowski
232
232
  @driver.sc_disable_all_autoscrolling
233
233
 
234
234
  mouse_down_at mouse_offset_x, mouse_offset_y
235
+
236
+ # Need to incoporate an intentional sleep so sproutcore
237
+ # has enough time to do its thing
238
+ sleep 0.2
239
+
235
240
  mouse_move_at mouse_offset_x, mouse_offset_y
236
-
241
+
237
242
  # Make sure the element we are dragging relative to is visible
238
243
  relative_to.scroll_to_visible if relative_to.kind_of? PositionedElement
239
244
 
240
245
  rel_pos = relative_position(x, y, relative_to)
241
246
  mouse_move_at rel_pos.x, rel_pos.y
242
-
247
+
243
248
  rel_pos = relative_position(x, y, relative_to)
244
249
  mouse_up_at rel_pos.x, rel_pos.y
245
-
250
+
246
251
  # Enable autoscrolling and mouse move events since we have completed the
247
252
  # drag and drop operation
248
253
  @driver.sc_enable_all_autoscrolling
249
254
  @driver.sc_enable_mouse_move_event
250
-
251
- stall :drag
252
255
  end
253
256
 
254
257
  def drag_to(source, offset_x=nil, offset_y=nil, *params)
@@ -6,10 +6,6 @@
6
6
  module Lebowski
7
7
  module Foundation
8
8
 
9
- SC_BUTTON1_STATUS = 'button1'
10
- SC_BUTTON2_STATUS = 'button2'
11
- SC_BUTTON3_STATUS = 'button3'
12
-
13
9
  module Panes
14
10
 
15
11
  #
@@ -35,9 +31,9 @@ module Lebowski
35
31
 
36
32
  ALERT_PROPERTY_TYPE = 'icon'
37
33
 
38
- BUTTON_ONE = 'buttonOne'
39
- BUTTON_TWO = 'buttonTwo'
40
- BUTTON_THREE = 'buttonThree'
34
+ BUTTON_ONE = 'button1'
35
+ BUTTON_TWO = 'button2'
36
+ BUTTON_THREE = 'button3'
41
37
 
42
38
  BUTTONS = [BUTTON_ONE, BUTTON_TWO, BUTTON_THREE]
43
39
 
@@ -19,6 +19,10 @@ module Lebowski
19
19
  return @menu_items
20
20
  end
21
21
 
22
+ def click_item(title)
23
+ menu_items.click title
24
+ end
25
+
22
26
  protected
23
27
 
24
28
  def create_menu_item_array()
@@ -33,15 +37,16 @@ module Lebowski
33
37
  include Lebowski
34
38
 
35
39
  def initialize(parent, *params)
36
- super(parent, 'menuItemViews', 'length', *params)
40
+ super(parent, 'items', 'length', *params)
41
+ @itemTitleKey = @parent['itemTitleKey']
37
42
  end
38
43
 
39
44
  def click(title)
40
45
  menu_item = nil
41
46
  if title.kind_of? String
42
- menu_item = find_first({ :title => /^#{title}$/i })
47
+ menu_item = find_first({ @itemTitleKey => /^#{title}$/i })
43
48
  elsif title.kind_of? Regexp
44
- menu_item = find_first({ :title => title })
49
+ menu_item = find_first({ @itemTitleKey => title })
45
50
  else
46
51
  raise ArgumentInvalidTypeError.new "title", title, String, Regexp
47
52
  end
@@ -50,45 +55,9 @@ module Lebowski
50
55
 
51
56
  protected
52
57
 
53
- def find_indexes_process_filter(filter)
54
- processed_filter = {}
55
-
56
- @title_flag = :no_flag
57
-
58
- filter.each do |key, value|
59
- case key
60
- when :title
61
- @title_flag = value
62
- else
63
- processed_filter[key] = value
64
- end
65
- end
66
-
67
- return processed_filter
68
- end
69
-
70
- def find_indexes_process_indexes(indexes)
71
- processed_indexes = []
72
-
73
- indexes.each do |index|
74
- if @title_flag != :no_flag
75
- next if (not menu_item_has_title?(index, @title_flag))
76
- end
77
-
78
- processed_indexes << index
79
- end
80
-
81
- return processed_indexes
82
- end
83
-
84
- private
85
-
86
- def menu_item_has_title?(index, title)
87
- menu_item = self[index]
88
- @valueKey = @parent['itemTitleKey'] if @valueKey.nil?
89
- value = menu_item["content.#{@valueKey}"]
90
- return (value =~ title).kind_of?(Integer) if title.kind_of?(Regexp)
91
- return (value == title)
58
+ def create_object(index, expected_type=nil)
59
+ rel_path = "_menuView.childViews.#{index}"
60
+ return @parent[rel_path, expected_type]
92
61
  end
93
62
 
94
63
  end
@@ -16,19 +16,7 @@ module Lebowski
16
16
 
17
17
  # A value the view's isSelected property can return other than a boolean value
18
18
  MIXED_STATE = '__MIXED__'
19
-
20
- #
21
- # @override
22
- #
23
- # Need to perform a basic click so that the view will respond correctly
24
- #
25
- def click()
26
- mouse_down
27
- mouse_up
28
- basic_click
29
- stall :click
30
- end
31
-
19
+
32
20
  def deselect()
33
21
  if in_mixed_state?
34
22
  click
@@ -21,6 +21,10 @@ module Lebowski
21
21
  double_click
22
22
  edit_inline_text_field value
23
23
  click
24
+
25
+ # Need to incoporate an intentional sleep so sproutcore
26
+ # has enough time to do its thing
27
+ sleep 0.2
24
28
  end
25
29
 
26
30
  end
@@ -18,6 +18,10 @@ module Lebowski
18
18
  mouse_move
19
19
  mouse_down
20
20
  mouse_up
21
+
22
+ # Need to incoporate an intentional sleep so sproutcore
23
+ # has enough time to do its thing
24
+ sleep 0.2
21
25
  end
22
26
 
23
27
  end
@@ -20,13 +20,38 @@ module Lebowski
20
20
  end
21
21
 
22
22
  def buttons()
23
- if @items.nil?
24
- @items = Support::SimpleItemArray.new self, '.sc-radio-button'
25
- end
23
+ @items = create_simple_item_array if @items.nil?
26
24
  return @items
27
25
  end
28
26
 
27
+ protected
28
+
29
+ def create_simple_item_array()
30
+ return Support::RadioViewItemArray.new self
31
+ end
32
+
29
33
  end
34
+
35
+ module Support
36
+
37
+ class RadioViewItemArray < SimpleItemArray
38
+
39
+ SELECTOR = '.sc-radio-button'
40
+
41
+ def click_with_index(value)
42
+ cq = @parent.core_query(SELECTOR)
43
+ cq[value].mouse_down
44
+ cq.done
45
+
46
+ cq = @parent.core_query(SELECTOR)
47
+ cq[value].mouse_up
48
+ cq.done
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
30
55
  end
31
56
  end
32
57
  end
@@ -30,7 +30,7 @@ module Lebowski
30
30
  protected
31
31
 
32
32
  def create_simple_item_array()
33
- return Support::SegmentItemArray.new self, '.sc-segment'
33
+ return Support::SegmentItemArray.new self
34
34
  end
35
35
 
36
36
  end
@@ -81,6 +81,11 @@ module Lebowski
81
81
  item = self[index]
82
82
  item.deselect
83
83
  end
84
+
85
+ def click_with_index(value)
86
+ segment = @parent["childViews.#{value}", View]
87
+ segment.click if (not segment.nil?)
88
+ end
84
89
 
85
90
  protected
86
91
 
@@ -16,19 +16,19 @@ module Lebowski
16
16
  representing_sc_class 'SC.SelectButtonView'
17
17
 
18
18
  def display_menu
19
- self.mouse_down if !menu_displayed?
19
+ click if !has_menu_displayed?
20
20
  end
21
21
 
22
22
  def hide_menu
23
- menu.click_off if menu_displayed?
23
+ menu.click_off if has_menu_displayed?
24
24
  end
25
25
 
26
- def menu_displayed?
26
+ def has_menu_displayed?
27
27
  return (not menu.nil?)
28
28
  end
29
29
 
30
30
  def menu
31
- @menu = get_root_application_object.responding_panes.find_first(MenuPane)
31
+ @menu = self['pane.rootResponder.menuPane']
32
32
  if not @menu.nil?
33
33
  @menu = @menu.represent_as(SelectButtonMenu)
34
34
  @menu.select_button = self
@@ -99,7 +99,8 @@ module Lebowski
99
99
  # @see #select
100
100
  #
101
101
  def select_with_value(val)
102
- option_locator = "value=regexi:^(nu|st|sc)#{val}$"
102
+ guid = @driver.get_sc_guid(val)
103
+ option_locator = "value=regexi:^#{guid}$"
103
104
  @driver.sc_select(:view, option_locator, self.abs_path)
104
105
  stall :select
105
106
  end
@@ -40,22 +40,17 @@ module Lebowski
40
40
  include Lebowski::Foundation
41
41
  include Lebowski::Foundation::Views
42
42
 
43
- def initialize(parent, item_selector, value_rel_path=nil, items_rel_path=nil, item_title_key=nil, item_value_key=nil)
43
+ def initialize(parent)
44
44
  if not parent.kind_of? View
45
45
  raise ArgumentInvalidTypeError.new "parent", parent, View
46
46
  end
47
-
48
- if not item_selector.kind_of? String
49
- raise ArgumentInvalidTypeError.new "item_selector", item_selector, String
50
- end
51
47
 
52
48
  @parent = parent
53
49
  @driver = parent.driver
54
- @item_selector = item_selector
55
- @value_rel_path = value_rel_path.nil? ? 'value' : value_rel_path
56
- @items_rel_path = items_rel_path.nil? ? 'items' : items_rel_path
57
- @item_title_key = item_title_key.nil? ? parent['itemTitleKey'] : parent[item_title_key]
58
- @item_value_key = item_value_key.nil? ? parent['itemValueKey'] : parent[item_value_key]
50
+ @value_rel_path = 'value'
51
+ @items_rel_path = 'items'
52
+ @item_title_key = parent['itemTitleKey']
53
+ @item_value_key = parent['itemValueKey']
59
54
  end
60
55
 
61
56
  def selected?(value)
@@ -170,15 +165,9 @@ module Lebowski
170
165
  end
171
166
  end
172
167
 
168
+ # Must be implemented by a subclass
173
169
  def click_with_index(value)
174
- cq = @parent.core_query(@item_selector)
175
- cq[value].mouse_down
176
- cq[value].basic_click # Required for slightly older versions of SC (pre 1.0)
177
- cq.done
178
-
179
- cq = @parent.core_query(@item_selector)
180
- cq[value].mouse_up
181
- cq.done
170
+ # NO-OP
182
171
  end
183
172
 
184
173
  def click_with_title(value)
@@ -33,8 +33,9 @@ module Lebowski
33
33
 
34
34
  # SC Object Foundation Selenium Calls
35
35
 
36
- def get_sc_guid(scpath)
37
- return __string_command("getScGuid", [scpath])
36
+ def get_sc_guid(val)
37
+ encoded_params = ObjectEncoder.encode_hash({ :val => val })
38
+ return __string_command("getScGuid", [encoded_params])
38
39
  end
39
40
 
40
41
  def get_sc_object_class_name(scpath)
@@ -246,13 +247,13 @@ module Lebowski
246
247
  end
247
248
 
248
249
  def sc_key_down(type, key, *params)
249
- if key == :meta_key
250
+ if key == :meta_key or key == :meta
250
251
  meta_key_down
251
- elsif key == :alt_key
252
+ elsif key == :alt_key or key == :alt
252
253
  alt_key_down
253
- elsif key == :ctrl_key
254
+ elsif key == :ctrl_key or key == :ctrl
254
255
  control_key_down
255
- elsif key == :shift_key
256
+ elsif key == :shift_key or key == :shift
256
257
  shift_key_down
257
258
  elsif key.kind_of? Symbol
258
259
  __remote_control_command("scFunctionKeyDown", [__locator(type, *params), key.to_s])
@@ -263,13 +264,13 @@ module Lebowski
263
264
  end
264
265
 
265
266
  def sc_key_up(type, key, *params)
266
- if key == :meta_key
267
+ if key == :meta_key or key == :meta
267
268
  meta_key_up
268
- elsif key == :alt_key
269
+ elsif key == :alt_key or key == :alt
269
270
  alt_key_up
270
- elsif key == :ctrl_key
271
+ elsif key == :ctrl_key or key == :ctrl
271
272
  control_key_up
272
- elsif key == :shift_key
273
+ elsif key == :shift_key or key == :shift
273
274
  shift_key_up
274
275
  elsif key.kind_of? Symbol
275
276
  __remote_control_command("scFunctionKeyUp", [__locator(type, *params), key.to_s])
@@ -6,8 +6,8 @@
6
6
  module Lebowski
7
7
  module Version
8
8
  MAJOR = 0
9
- MINOR = 3
10
- PATCH = "3.pre.0"
9
+ MINOR = 4
10
+ PATCH = 0
11
11
  BUILD = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -38,18 +38,41 @@ var $App = null;
38
38
  */
39
39
  var ScExt = {};
40
40
 
41
+ /**
42
+ Use this method instead of SC's typeOf method to check a value's type.
43
+
44
+ This method handles both SC 1.6 and 1.5. Unfortunately SC.typeOf for
45
+ SC 1.5 can return an incorrect result that will end up prevent the
46
+ rest of Lebowski from working. This method will correct the result.
47
+ */
48
+ ScExt.typeOf = function(value) {
49
+ var type = $SC.typeOf(value);
50
+
51
+ if (type === $SC.T_ERROR && $SC.VERSION.match(/^1.5/)) {
52
+ if ($SC.Error && value instanceof $SC.Error) {
53
+ type = $SC.T_ERROR;
54
+ } else if (value instanceof $SC.Object) {
55
+ type = $SC.T_OBJECT;
56
+ } else {
57
+ type = $SC.T_HASH;
58
+ }
59
+ }
60
+
61
+ return type;
62
+ };
63
+
41
64
  /**
42
65
  Checks if the given value is indeed an SC.Object
43
66
  */
44
67
  ScExt.isScObject = function(obj) {
45
- return $SC.typeOf(obj) === $SC.T_OBJECT;
68
+ return ScExt.typeOf(obj) === $SC.T_OBJECT;
46
69
  };
47
70
 
48
71
  /**
49
72
  Checks if the given value is either an instance of SC.Object or a JS hash object
50
73
  */
51
74
  ScExt.isObject = function(obj) {
52
- var type = $SC.typeOf(obj);
75
+ var type = ScExt.typeOf(obj);
53
76
  return type === $SC.T_OBJECT || type === $SC.T_HASH;
54
77
  };
55
78
 
@@ -279,7 +302,7 @@ ScExt.PathParser = {
279
302
 
280
303
  for (var i = 1; i < parts.length; i++) {
281
304
  if (this._isArrayIndex(parts[i])) {
282
- if ($SC.typeOf(objPathChain[i - 1]) === $SC.T_FUNCTION) {
305
+ if (ScExt.typeOf(objPathChain[i - 1]) === $SC.T_FUNCTION) {
283
306
  // Last part is a function, therefore invoke the function with the index
284
307
  var target = objPathChain[i - 2];
285
308
  var func = objPathChain[i - 1];
@@ -290,10 +313,12 @@ ScExt.PathParser = {
290
313
  current_obj = this._getObjectFromArray(array, parts[i]);
291
314
  }
292
315
  } else {
293
- if ($SC.typeOf(current_obj.getPath) === $SC.T_FUNCTION) {
294
- // Object is a SC object. Use the get method
316
+ if (ScExt.typeOf(current_obj.getPath) === $SC.T_FUNCTION && current_obj !== $SC) {
317
+ // Object is a SC object. Use the get method. Need to be mindful of the SC
318
+ // root object since it also has getPath but doesn't behave the same way as
319
+ // getPath on regular SC objects.
295
320
  current_obj = current_obj.getPath(parts[i]);
296
- } else if ($SC.typeOf(current_obj.get) === $SC.T_FUNCTION) {
321
+ } else if (ScExt.typeOf(current_obj.get) === $SC.T_FUNCTION) {
297
322
  current_obj = current_obj.get(parts[i]);
298
323
  } else {
299
324
  // Object is just a plain old JS object
@@ -353,7 +378,7 @@ ScExt.MouseEventSimulation = {
353
378
 
354
379
  simulateEvent: function(mouseEvent, locator, x, y, button) {
355
380
  var element = selenium.browserbot.findElement(locator),
356
- coord = element ? $SC.viewportOffset(element) : { x: 0, y: 0 },
381
+ coord = element ? $SC.offset(element) : { x: 0, y: 0 },
357
382
  width = element ? element.clientWidth : 0,
358
383
  height = element ? element.clientHeight : 0,
359
384
  which = 1;
@@ -377,7 +402,7 @@ ScExt.MouseEventSimulation = {
377
402
  }
378
403
  }
379
404
 
380
- var coords = element ? $SC.viewportOffset(element) : { x: 0, y: 0 },
405
+ var coords = element ? $SC.offset(element) : { x: 0, y: 0 },
381
406
  clientX = coords.x + x,
382
407
  clientY = coords.y + y;
383
408
 
@@ -1587,7 +1612,7 @@ Selenium.prototype.doScEnableMouseMoveEvent = function() {
1587
1612
  */
1588
1613
  Selenium.prototype.getScTypeOf = function(path) {
1589
1614
  var value = $ScPath.getPath(path);
1590
- return $SC.typeOf(value);
1615
+ return ScExt.typeOf(value);
1591
1616
  };
1592
1617
 
1593
1618
  /**
@@ -1605,9 +1630,13 @@ Selenium.prototype.getScTypeOfArrayContent = function(path) {
1605
1630
  /**
1606
1631
  Returns a SproutCore object's GUID
1607
1632
  */
1608
- Selenium.prototype.getScGuid = function(path) {
1609
- var value = $ScPath.getPath(path, 'SC.Object');
1610
- var guid = $SC.guidFor(value);
1633
+ Selenium.prototype.getScGuid = function(params) {
1634
+ params = ScExt.ObjectDecoder.decodeHash(params);
1635
+ var value = params.val;
1636
+ if ($SC.typeOf(value) === $SC.T_STRING) {
1637
+ value = $ScPath.getPath(value, 'SC.Object');
1638
+ }
1639
+ var guid = $SC.guidFor(!!value ? value : params.val);
1611
1640
  return guid;
1612
1641
  };
1613
1642
 
@@ -1689,7 +1718,7 @@ Selenium.prototype.getScViewFrame = function(path) {
1689
1718
  Selenium.prototype.getScElementWindowPosition = function(path) {
1690
1719
  var element = this.browserbot.findElement(path);
1691
1720
  if (!element) return null;
1692
- var coords = $SC.viewportOffset(element);
1721
+ var coords = $SC.offset(element);
1693
1722
  if (!coords) return null;
1694
1723
  return [coords.x, coords.y];
1695
1724
  };
@@ -2019,4 +2048,4 @@ PageBot.prototype.locateElementByScCoreQuery = function(text) {
2019
2048
  PageBot.prototype.evaluateCssSelectorCount = function(css, document) {
2020
2049
  var elements = eval_css(css, document);
2021
2050
  return elements.length;
2022
- };
2051
+ };
metadata CHANGED
@@ -1,185 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lebowski
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
5
- segments:
6
- - 0
7
- - 3
8
- - 3
9
- - pre
10
- - 0
11
- version: 0.3.3.pre.0
4
+ prerelease:
5
+ version: 0.4.0
12
6
  platform: ruby
13
7
  authors:
14
8
  - Michael Cohen
9
+ - Apple Inc. and contributors
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
13
 
19
- date: 2011-03-12 00:00:00 -08:00
14
+ date: 2011-08-22 00:00:00 -07:00
20
15
  default_executable:
21
16
  dependencies:
22
17
  - !ruby/object:Gem::Dependency
23
- name: selenium-client
18
+ name: rspec
19
+ prerelease: false
24
20
  requirement: &id001 !ruby/object:Gem::Requirement
25
21
  none: false
26
22
  requirements:
27
23
  - - ~>
28
24
  - !ruby/object:Gem::Version
29
- segments:
30
- - 1
31
- - 2
32
- - 18
33
- version: 1.2.18
25
+ version: 2.5.0
34
26
  type: :runtime
35
- prerelease: false
36
27
  version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rspec
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- segments:
45
- - 2
46
- - 1
47
- - 0
48
- version: 2.1.0
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: bundler
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
57
- - - ~>
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 1
61
- - 0
62
- - 0
63
- version: 1.0.0
64
- type: :development
65
- prerelease: false
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: jeweler
69
- requirement: &id004 !ruby/object:Gem::Requirement
70
- none: false
71
- requirements:
72
- - - ~>
73
- - !ruby/object:Gem::Version
74
- segments:
75
- - 1
76
- - 5
77
- - 1
78
- version: 1.5.1
79
- type: :development
80
- prerelease: false
81
- version_requirements: *id004
82
- - !ruby/object:Gem::Dependency
83
- name: rcov
84
- requirement: &id005 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- segments:
90
- - 0
91
- version: "0"
92
- type: :development
93
- prerelease: false
94
- version_requirements: *id005
95
28
  - !ruby/object:Gem::Dependency
96
29
  name: selenium-client
97
- requirement: &id006 !ruby/object:Gem::Requirement
30
+ prerelease: false
31
+ requirement: &id002 !ruby/object:Gem::Requirement
98
32
  none: false
99
33
  requirements:
100
34
  - - ~>
101
35
  - !ruby/object:Gem::Version
102
- segments:
103
- - 1
104
- - 2
105
- - 18
106
36
  version: 1.2.18
107
37
  type: :runtime
108
- prerelease: false
109
- version_requirements: *id006
38
+ version_requirements: *id002
110
39
  - !ruby/object:Gem::Dependency
111
40
  name: rspec
112
- requirement: &id007 !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- segments:
118
- - 2
119
- - 1
120
- - 0
121
- version: 2.1.0
122
- type: :runtime
123
41
  prerelease: false
124
- version_requirements: *id007
125
- - !ruby/object:Gem::Dependency
126
- name: rspec
127
- requirement: &id008 !ruby/object:Gem::Requirement
42
+ requirement: &id003 !ruby/object:Gem::Requirement
128
43
  none: false
129
44
  requirements:
130
45
  - - ~>
131
46
  - !ruby/object:Gem::Version
132
- segments:
133
- - 2
134
- - 1
135
- - 0
136
- version: 2.1.0
47
+ version: 2.5.0
137
48
  type: :development
138
- prerelease: false
139
- version_requirements: *id008
49
+ version_requirements: *id003
140
50
  - !ruby/object:Gem::Dependency
141
51
  name: bundler
142
- requirement: &id009 !ruby/object:Gem::Requirement
143
- none: false
144
- requirements:
145
- - - ~>
146
- - !ruby/object:Gem::Version
147
- segments:
148
- - 1
149
- - 0
150
- - 0
151
- version: 1.0.0
152
- type: :development
153
52
  prerelease: false
154
- version_requirements: *id009
155
- - !ruby/object:Gem::Dependency
156
- name: jeweler
157
- requirement: &id010 !ruby/object:Gem::Requirement
53
+ requirement: &id004 !ruby/object:Gem::Requirement
158
54
  none: false
159
55
  requirements:
160
56
  - - ~>
161
57
  - !ruby/object:Gem::Version
162
- segments:
163
- - 1
164
- - 5
165
- - 1
166
- version: 1.5.1
167
- type: :development
168
- prerelease: false
169
- version_requirements: *id010
170
- - !ruby/object:Gem::Dependency
171
- name: rcov
172
- requirement: &id011 !ruby/object:Gem::Requirement
173
- none: false
174
- requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
177
- segments:
178
- - 0
179
- version: "0"
58
+ version: 1.0.0
180
59
  type: :development
181
- prerelease: false
182
- version_requirements: *id011
60
+ version_requirements: *id004
183
61
  description: " \n Lebowski is a test automation framework designed for full feature, integration, and \n regression testing of SproutCore applications.\n \n"
184
62
  email: michael.lee.cohen@gmail.com
185
63
  executables:
@@ -189,19 +67,10 @@ executables:
189
67
  extensions: []
190
68
 
191
69
  extra_rdoc_files:
192
- - README.md
193
- files:
194
- - Gemfile
195
70
  - History.md
196
- - License.txt
197
71
  - README.md
198
- - Rakefile
199
- - bin/lebowski
200
- - bin/lebowski-spec
201
- - bin/lebowski-start-server
202
- - lib/lebowski.rb
72
+ files:
203
73
  - lib/lebowski/core.rb
204
- - lib/lebowski/foundation.rb
205
74
  - lib/lebowski/foundation/application.rb
206
75
  - lib/lebowski/foundation/core.rb
207
76
  - lib/lebowski/foundation/core_query.rb
@@ -251,7 +120,7 @@ files:
251
120
  - lib/lebowski/foundation/views/text_field.rb
252
121
  - lib/lebowski/foundation/views/view.rb
253
122
  - lib/lebowski/foundation/views/web.rb
254
- - lib/lebowski/rspec.rb
123
+ - lib/lebowski/foundation.rb
255
124
  - lib/lebowski/rspec/core.rb
256
125
  - lib/lebowski/rspec/matchers/be.rb
257
126
  - lib/lebowski/rspec/matchers/has.rb
@@ -263,7 +132,7 @@ files:
263
132
  - lib/lebowski/rspec/operators/operator.rb
264
133
  - lib/lebowski/rspec/operators/that.rb
265
134
  - lib/lebowski/rspec/util.rb
266
- - lib/lebowski/runtime.rb
135
+ - lib/lebowski/rspec.rb
267
136
  - lib/lebowski/runtime/errors/remote_control_command_execution_error.rb
268
137
  - lib/lebowski/runtime/errors/remote_control_command_timeout_error.rb
269
138
  - lib/lebowski/runtime/errors/remote_control_error.rb
@@ -271,7 +140,7 @@ files:
271
140
  - lib/lebowski/runtime/object_encoder.rb
272
141
  - lib/lebowski/runtime/sprout_core_driver.rb
273
142
  - lib/lebowski/runtime/sprout_core_extensions.rb
274
- - lib/lebowski/scui.rb
143
+ - lib/lebowski/runtime.rb
275
144
  - lib/lebowski/scui/mixins/link_support.rb
276
145
  - lib/lebowski/scui/mixins/node_item_view_support.rb
277
146
  - lib/lebowski/scui/mixins/terminal_view_support.rb
@@ -281,11 +150,15 @@ files:
281
150
  - lib/lebowski/scui/views/date_picker.rb
282
151
  - lib/lebowski/scui/views/linkit.rb
283
152
  - lib/lebowski/scui/views/select_field_tab.rb
153
+ - lib/lebowski/scui.rb
284
154
  - lib/lebowski/version.rb
285
- - resources/README
286
- - resources/selenium-server.jar
155
+ - lib/lebowski.rb
156
+ - History.md
157
+ - README.md
287
158
  - resources/user-extensions.js
288
- - spec/spec_helper.rb
159
+ - bin/lebowski
160
+ - bin/lebowski-spec
161
+ - bin/lebowski-start-server
289
162
  has_rdoc: true
290
163
  homepage: http://github.com/FrozenCanuck/Lebowski
291
164
  licenses:
@@ -293,7 +166,7 @@ licenses:
293
166
  post_install_message: |
294
167
  **************************************************
295
168
 
296
- Thank you for installing lebowski-0.3.3.pre.0
169
+ Thank you for installing lebowski-0.4.0
297
170
 
298
171
  Please be sure to read the README.md and History.md
299
172
  for useful information on how to use this framework
@@ -311,31 +184,25 @@ rdoc_options: []
311
184
 
312
185
  require_paths:
313
186
  - lib
187
+ - lib
314
188
  required_ruby_version: !ruby/object:Gem::Requirement
315
189
  none: false
316
190
  requirements:
317
191
  - - ">="
318
192
  - !ruby/object:Gem::Version
319
- hash: 1632185460177014276
320
- segments:
321
- - 0
322
- version: "0"
193
+ version: 1.9.0
323
194
  required_rubygems_version: !ruby/object:Gem::Requirement
324
195
  none: false
325
196
  requirements:
326
- - - ">"
197
+ - - ">="
327
198
  - !ruby/object:Gem::Version
328
- segments:
329
- - 1
330
- - 3
331
- - 1
332
- version: 1.3.1
199
+ version: "0"
333
200
  requirements: []
334
201
 
335
202
  rubyforge_project:
336
- rubygems_version: 1.3.7
203
+ rubygems_version: 1.6.2
337
204
  signing_key:
338
205
  specification_version: 3
339
- summary: A test automation framework for SproutCore
206
+ summary: Lebowski is a test integration automation framework for SproutCore
340
207
  test_files: []
341
208
 
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem "selenium-client", "~> 1.2.18"
4
- gem "rspec", "~> 2.1.0"
5
-
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "bundler", "~> 1.0.0"
10
- gem "jeweler", "~> 1.5.1"
11
- gem "rcov", ">= 0"
12
- end
data/License.txt DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010, 2011 Michael Cohen <http://frozencanuck.wordpress.com>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,58 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
- begin
5
- Bundler.setup(:default, :development)
6
- rescue Bundler::BundlerError => e
7
- $stderr.puts e.message
8
- $stderr.puts "Run `bundle install` to install missing gems"
9
- exit e.status_code
10
- end
11
-
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- require './lib/lebowski/version.rb'
16
-
17
- Jeweler::Tasks.new do |gem|
18
- gem.name = 'lebowski'
19
- gem.version = Lebowski::Version::STRING
20
- gem.homepage = 'http://github.com/FrozenCanuck/Lebowski'
21
- gem.license = 'MIT'
22
- gem.summary = 'A test automation framework for SproutCore'
23
- gem.description = <<-DESCRIPTION
24
-
25
- Lebowski is a test automation framework designed for full feature, integration, and
26
- regression testing of SproutCore applications.
27
-
28
- DESCRIPTION
29
- gem.email = 'michael.lee.cohen@gmail.com'
30
- gem.authors = ['Michael Cohen']
31
- gem.add_dependency 'selenium-client', '~> 1.2.18'
32
- gem.add_dependency 'rspec', '~> 2.1.0'
33
- gem.add_development_dependency 'rspec', '~> 2.1.0'
34
- gem.add_development_dependency 'bundler', '~> 1.0.0'
35
- gem.add_development_dependency 'jeweler', '~> 1.5.1'
36
- gem.add_development_dependency 'rcov', '>= 0'
37
- gem.executables = ['lebowski', 'lebowski-spec', 'lebowski-start-server']
38
- gem.files.exclude 'examples'
39
- gem.test_files = []
40
- gem.post_install_message = <<-POST_INSTALL_MESSAGE
41
- #{'*'*50}
42
-
43
- Thank you for installing lebowski-#{Lebowski::Version::STRING}
44
-
45
- Please be sure to read the README.md and History.md
46
- for useful information on how to use this framework
47
- and about this release.
48
-
49
- For more information go to the following web sites:
50
-
51
- http://github.com/FrozenCanuck/Lebowski
52
- http://frozencanuck.wordpress.com
53
- http://www.sproutcore.com
54
-
55
- #{'*'*50}
56
- POST_INSTALL_MESSAGE
57
- end
58
- Jeweler::RubygemsDotOrgTasks.new
data/resources/README DELETED
@@ -1 +0,0 @@
1
- The selenium-server.jar is part of the Selenium Framework (http://seleniumhq.org)
Binary file
data/spec/spec_helper.rb DELETED
@@ -1 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../lib/lebowski')