appium_lib 0.5.16 → 0.6.0

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.
@@ -361,7 +361,7 @@ module Appium::Android
361
361
  # Returns a string containing interesting elements.
362
362
  # @return [String]
363
363
  def get_inspect
364
- @selendroid ? get_selendroid_inspect : get_android_inspect
364
+ @device == :selendroid ? get_selendroid_inspect : get_android_inspect
365
365
  end
366
366
 
367
367
  # Intended for use with console.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Appium
3
3
  # Version and Date are defined on the 'Appium' module, not 'Appium::Common'
4
- VERSION = '0.5.16' unless defined? ::Appium::VERSION
5
- DATE = '2013-07-26' unless defined? ::Appium::DATE
4
+ VERSION = '0.6.0' unless defined? ::Appium::VERSION
5
+ DATE = '2013-08-05' unless defined? ::Appium::DATE
6
6
  end
@@ -52,10 +52,15 @@ def load_appium_txt opts
52
52
 
53
53
  update data, 'APP_PATH', 'APP_APK', 'APP_PACKAGE',
54
54
  'APP_ACTIVITY', 'APP_WAIT_ACTIVITY',
55
- 'SELENDROID'
55
+ 'DEVICE'
56
56
 
57
57
  # Ensure app path is absolute
58
- ENV['APP_PATH'] = File.expand_path ENV['APP_PATH'] if ENV['APP_PATH']
58
+ ENV['APP_PATH'] = File.expand_path ENV['APP_PATH'] if ENV['APP_PATH'] &&
59
+ !ENV['APP_PATH'].empty?
60
+
61
+ if ! %w(ios android selendroid).include? ENV['DEVICE']
62
+ raise 'DEVICE must be ios, android, or selendroid'
63
+ end
59
64
  end
60
65
 
61
66
  # return list of require files as an array
@@ -74,6 +79,14 @@ def load_appium_txt opts
74
79
  end
75
80
  end
76
81
 
82
+ # Fix uninitialized constant Minitest (NameError)
83
+ module Minitest
84
+ # Fix superclass mismatch for class Spec
85
+ class Runnable; end
86
+ class Test < Runnable; end
87
+ class Spec < Test; end
88
+ end
89
+
77
90
  module Appium
78
91
  add_to_path __FILE__
79
92
 
@@ -105,10 +118,11 @@ module Appium
105
118
  class Driver
106
119
  @@loaded = false
107
120
 
108
- attr_reader :default_wait, :app_path, :app_name, :selendroid,
121
+ attr_reader :default_wait, :app_path, :app_name, :device,
109
122
  :app_package, :app_activity, :app_wait_activity,
110
- :sauce_username, :sauce_access_key, :port, :os, :debug
123
+ :sauce_username, :sauce_access_key, :port, :debug
111
124
  # Creates a new driver.
125
+ # :device is :android, :ios, or :selendroid
112
126
  #
113
127
  # ```ruby
114
128
  # # Options include:
@@ -120,11 +134,12 @@ module Appium
120
134
  # require 'appium_lib'
121
135
  #
122
136
  # # Start iOS driver
123
- # app = { app_path: '/path/to/MyiOS.app'}
137
+ # app = { device: :ios, app_path: '/path/to/MyiOS.app'}
124
138
  # Appium::Driver.new(app).start_driver
125
139
  #
126
140
  # # Start Android driver
127
- # apk = { app_path: '/path/to/the.apk',
141
+ # apk = { device: :android
142
+ # app_path: '/path/to/the.apk',
128
143
  # app_package: 'com.example.pkg',
129
144
  # app_activity: 'act.Start',
130
145
  # app_wait_activity: 'act.Start'
@@ -152,10 +167,6 @@ module Appium
152
167
  # The name to use for the test run on Sauce.
153
168
  @app_name = opts.fetch :app_name, ENV['APP_NAME']
154
169
 
155
- # If Android, this will toggle selendroid as a device
156
- @selendroid = opts.fetch :selendroid, ENV['SELENDROID']
157
- @selendroid = 'selendroid' if @selendroid
158
-
159
170
  # Android app package
160
171
  @app_package = opts.fetch :app_package, ENV['APP_PACKAGE']
161
172
 
@@ -173,12 +184,13 @@ module Appium
173
184
 
174
185
  @port = opts.fetch :port, ENV['PORT'] || 4723
175
186
 
176
- @os = :ios
177
- @os = :android if @app_path.match /\.apk/i
187
+ # :ios, :android, :selendroid
188
+ @device = opts.fetch :device, ENV['DEVICE'] || :ios
189
+ @device = @device.intern # device must be a symbol
178
190
 
179
191
  # load common methods
180
192
  extend Appium::Common
181
- if @os == :android
193
+ if @device == :android
182
194
  raise 'APP_ACTIVITY must be set.' if @app_activity.nil?
183
195
 
184
196
  # load Android specific methods
@@ -197,7 +209,7 @@ module Appium
197
209
  puts "Debug is: #{@debug}"
198
210
  if @debug
199
211
  ap opts unless opts.empty?
200
- puts "OS is: #{@os}"
212
+ puts "Device is: #{@device}"
201
213
  patch_webdriver_bridge
202
214
  end
203
215
 
@@ -210,14 +222,18 @@ module Appium
210
222
  @@loaded = true
211
223
  # Promote Appium driver methods to Object instance methods.
212
224
  $driver.public_methods(false).each do | m |
213
- Object.class_eval do
225
+ # not MiniTest::Spec
226
+ ::Minitest::Spec.class_eval do
214
227
  define_method m do | *args, &block |
215
228
  begin
216
229
  # puts "[Object.class_eval] Calling super for '#{m}'"
217
230
  # prefer existing method.
218
231
  # super will invoke method missing on driver
219
232
  super(*args, &block)
220
- rescue NoMethodError
233
+ # minitest also defines a name method,
234
+ # so rescue argument error
235
+ # and call the name method on $driver
236
+ rescue NoMethodError, ArgumentError
221
237
  # puts "[Object.class_eval] '#{m}' not on super"
222
238
  $driver.send m, *args, &block if $driver.respond_to?(m)
223
239
  end
@@ -264,9 +280,8 @@ module Appium
264
280
  browserName: 'Android',
265
281
  platform: 'LINUX',
266
282
  version: '4.2',
267
- device: @selendroid || 'Android',
283
+ device: @device == :android ? 'Android' : 'selendroid',
268
284
  name: @app_name || 'Ruby Console Android Appium',
269
- app: absolute_app_path,
270
285
  :'app-package' => @app_package,
271
286
  :'app-activity' => @app_activity,
272
287
  :'app-wait-activity' => @app_wait_activity || @app_activity
@@ -281,14 +296,15 @@ module Appium
281
296
  platform: 'Mac 10.8',
282
297
  version: '6.0',
283
298
  device: 'iPhone Simulator',
284
- name: @app_name || 'Ruby Console iOS Appium',
285
- app: absolute_app_path
299
+ name: @app_name || 'Ruby Console iOS Appium'
286
300
  }
287
301
  end
288
302
 
289
303
  # @private
290
304
  def capabilities
291
- @os == :ios ? ios_capabilities : android_capabilities
305
+ caps = @device == :ios ? ios_capabilities : android_capabilities
306
+ caps[:app] = absolute_app_path unless @app_path.nil? || @app_path.empty?
307
+ caps
292
308
  end
293
309
 
294
310
  # Converts environment variable APP_PATH to an absolute path.
@@ -365,7 +381,7 @@ module Appium
365
381
  # Set timeout to a large number so that Appium doesn't quit
366
382
  # when no commands are entered after 60 seconds.
367
383
  # broken on selendroid: https://github.com/appium/appium/issues/513
368
- mobile :setCommandTimeout, timeout: 9999 unless @selendroid
384
+ mobile :setCommandTimeout, timeout: 9999 unless @device == :selendroid
369
385
 
370
386
  # Set implicit wait by default unless we're using Pry.
371
387
  @driver.manage.timeouts.implicit_wait = @default_wait unless defined? Pry
@@ -17,10 +17,11 @@ now swipe down until the end of the window - 10 pixels.
17
17
  Swiping inside the keyboard will not dismiss it.
18
18
  =end
19
19
  # type
20
- execute_script %(au.getElement('#{self.ref}').setValue('#{text}');)
20
+ $driver.execute_script %(au.getElement('#{self.ref}').setValue('#{text}');)
21
21
 
22
22
  # wait for keyboard
23
- wait_true { execute_script %(au.mainApp.keyboard().type() !== 'UIAElementNil') }
23
+ $driver.wait_true { $driver.execute_script %(au.mainApp.keyboard().type
24
+ () !== 'UIAElementNil') }
24
25
 
25
26
  # dismiss keyboard
26
27
  js = <<-JS
@@ -31,7 +32,7 @@ Swiping inside the keyboard will not dismiss it.
31
32
  }
32
33
  JS
33
34
 
34
- execute_script js
35
+ $driver.execute_script js
35
36
  end
36
37
  end
37
38
  end
data/readme.md CHANGED
@@ -35,11 +35,13 @@ require 'rubygems'
35
35
  require 'appium_lib'
36
36
 
37
37
  # Start iOS driver
38
- app = { app_path: '/path/to/MyiOS.app'}
38
+ app = { device: :ios, app_path: '/path/to/MyiOS.app'}
39
39
  Appium::Driver.new(app).start_driver
40
40
 
41
41
  # Start Android driver
42
- apk = { app_path: '/path/to/the.apk',
42
+ apk = {
43
+ device: :android
44
+ app_path: '/path/to/the.apk',
43
45
  app_package: 'com.example.pkg',
44
46
  app_activity: '.act.Start',
45
47
  app_wait_activity: '.act.Start'
@@ -1,3 +1,22 @@
1
+ #### v0.5.16 2013-07-26
2
+
3
+ - [bd71fb4](https://github.com/appium/ruby_lib/commit/bd71fb4e430608d32923c583c8d4d592f11a96fc) Release 0.5.16
4
+ - [7b83b85](https://github.com/appium/ruby_lib/commit/7b83b85c41caf25376414d978ff63d49ab22f057) Only return files that exist
5
+ - [1f0428d](https://github.com/appium/ruby_lib/commit/1f0428dca4e843a82de2d46be3c724e2dc7930c7) Fix keyboard race condition
6
+ - [c99ed34](https://github.com/appium/ruby_lib/commit/c99ed341c779fb3eff4ab92a95a4a773a1ce212f) Update docs.md
7
+ - [7103921](https://github.com/appium/ruby_lib/commit/71039210e1e0b7481df59210ce4addebcae7ba08) Fix link
8
+ - [f76ea9b](https://github.com/appium/ruby_lib/commit/f76ea9b42a728aae247f88f732879cda94101624) Add require support to appium.txt
9
+ - [12b8e59](https://github.com/appium/ruby_lib/commit/12b8e5938cb616015cb86d62e41ee9d29cace097) Update docs.md
10
+ - [7d6a8f2](https://github.com/appium/ruby_lib/commit/7d6a8f2fa728e616e7fd459cdeef0d5cce9064b4) Add current_app to docs
11
+ - [16ea945](https://github.com/appium/ruby_lib/commit/16ea9454941d84bb02ba4950aeea8df6d70cab26) Fix hide keyboard on iOS
12
+ - [ad9263c](https://github.com/appium/ruby_lib/commit/ad9263cbabb4e1c56bbe9fafe85b048f2a285c11) Add Sauce wait req
13
+ - [98ee244](https://github.com/appium/ruby_lib/commit/98ee244d460f6251c5c6cff8cc79ca8610cc6165) Add .clear example for textfield
14
+ - [d373071](https://github.com/appium/ruby_lib/commit/d3730717faba192cc66f5346c2847ecf6cb60e16) Fix activity name example in readme
15
+ - [50023f3](https://github.com/appium/ruby_lib/commit/50023f3a8201b0875025e5a94ec841fb23c35714) Fix Android version
16
+ - [c4d281a](https://github.com/appium/ruby_lib/commit/c4d281a62d7923f9e6a65fbc870cb1dc6a959849) Add Android set version code
17
+ - [5675f4a](https://github.com/appium/ruby_lib/commit/5675f4a03f8b20939e8cc1b5b13df795072d6553) Update readme.md
18
+
19
+
1
20
  #### v0.5.15 2013-07-03
2
21
 
3
22
  - [734fe68](https://github.com/appium/ruby_lib/commit/734fe6887f36aa1ad59ef7ce992ba2e2f4c8c7d3) Release 0.5.15
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.16
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-26 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver