appium_lib 0.19.1 → 0.21.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.
@@ -49,10 +49,20 @@ module Appium::Common
49
49
  # https://github.com/appium/appium/wiki/Automating-mobile-gestures
50
50
  # @return [OpenStruct] the relative x, y in a struct. ex: { x: 0.50, y: 0.20 }
51
51
  def location_rel
52
- xy = self.location
52
+ location = self.location
53
+ location_x = location.x.to_f
54
+ location_y = location.y.to_f
55
+
56
+ size = self.size
57
+ size_width = size.width.to_f
58
+ size_height = size.height.to_f
59
+
60
+ center_x = location_x + (size_width / 2.0)
61
+ center_y = location_y + (size_height / 2.0)
62
+
53
63
  w = $driver.window_size
54
- OpenStruct.new( x: "#{xy.x.to_f} / #{w.width.to_f}",
55
- y: "#{xy.y.to_f} / #{w.height.to_f}" )
64
+ OpenStruct.new( x: "#{center_x} / #{w.width.to_f}",
65
+ y: "#{center_y} / #{w.height.to_f}" )
56
66
  end
57
67
  end
58
68
  end # module Appium::Common
@@ -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.19.1' unless defined? ::Appium::VERSION
5
- DATE = '2014-02-25' unless defined? ::Appium::DATE
4
+ VERSION = '0.21.0' unless defined? ::Appium::VERSION
5
+ DATE = '2014-03-13' unless defined? ::Appium::DATE
6
6
  end
@@ -148,8 +148,6 @@ module Appium
148
148
  require_relative 'android/element/alert'
149
149
  require_relative 'android/element/generic'
150
150
  require_relative 'android/element/textfield'
151
- require_relative 'android/webview/javascript'
152
- require_relative 'android/webview/webview'
153
151
 
154
152
  def self.promote_singleton_appium_methods main_module
155
153
  raise 'Driver is nil' if $driver.nil?
@@ -324,8 +322,6 @@ module Appium
324
322
  # load common methods
325
323
  extend Appium::Common
326
324
  if @device == 'Android'
327
- raise 'APP_ACTIVITY must be set.' if @app_activity.nil?
328
-
329
325
  # load Android specific methods
330
326
  extend Appium::Android
331
327
  else
@@ -42,7 +42,7 @@ module Appium::Ios
42
42
  # @return [String] the completed JavaScript program
43
43
  def first_ele_js predicate
44
44
  (<<-JS).strip # remove trailing newline
45
- au.mainApp.getFirstWithPredicateWeighted("#{predicate}");
45
+ au.mainApp().getFirstWithPredicateWeighted("#{predicate}");
46
46
  JS
47
47
  end
48
48
 
@@ -51,7 +51,7 @@ module Appium::Ios
51
51
  # @return [String] the completed JavaScript program
52
52
  def all_ele_js predicate
53
53
  (<<-JS).strip # remove trailing newline
54
- au.mainApp.getAllWithPredicate("#{predicate}");
54
+ au.mainApp().getAllWithPredicate("#{predicate}");
55
55
  JS
56
56
  end
57
57
 
@@ -30,13 +30,13 @@ Swiping inside the keyboard will not dismiss it.
30
30
  # setValue will work, however the keyboard will never display
31
31
  # because users are normally not allowed to type into it.
32
32
  $driver.wait_true(5) do
33
- $driver.execute_script %(au.mainApp.keyboard().type() !== 'UIAElementNil')
33
+ $driver.execute_script %(au.mainApp().keyboard().type() !== 'UIAElementNil')
34
34
  end
35
35
 
36
36
  # dismiss keyboard
37
37
  js = <<-JS
38
- if (au.mainApp.keyboard().type() !== "UIAElementNil") {
39
- var startY = au.mainApp.keyboard().rect().origin.y - 10;
38
+ if (au.mainApp().keyboard().type() !== "UIAElementNil") {
39
+ var startY = au.mainApp().keyboard().rect().origin.y - 10;
40
40
  var endY = au.mainWindow.rect().size.height - 10;
41
41
  au.flickApp(0, startY, 0, endY);
42
42
  }
data/readme.md CHANGED
@@ -49,6 +49,9 @@ apk = {
49
49
  Appium::Driver.new(apk).start_driver
50
50
 
51
51
  # Define the methods on all objects.
52
+ # Note that this can also be scoped to limit the potential for conflicts.
53
+ # Example: Appium.promote_appium_methods ::Minitest::Spec
54
+ # Another alternative is to not promote at all. Instead access methods via $driver
52
55
  Appium.promote_appium_methods Object
53
56
  ```
54
57
 
@@ -1,3 +1,27 @@
1
+ #### v0.21.0 2014-03-13
2
+
3
+ - [db2df39](https://github.com/appium/ruby_lib/commit/db2df39eb6fc09e516e22334dd990699755c0509) Release 0.21.0
4
+ - [bf74d7a](https://github.com/appium/ruby_lib/commit/bf74d7a70c0f7cab8e4cb115d53d86c3720e2df3) Remove webview. Update gemspec
5
+
6
+
7
+ #### v0.20.0 2014-03-13
8
+
9
+ - [e79923f](https://github.com/appium/ruby_lib/commit/e79923f731c0f7ba85f280b512f5d82d365fd619) Release 0.20.0
10
+ - [9a6c6ea](https://github.com/appium/ruby_lib/commit/9a6c6eaf798938f8a483466e718e53483e3c0f02) Add bundle update to release rake task
11
+ - [093ba77](https://github.com/appium/ruby_lib/commit/093ba7712275b009d66146bcd9429ed9bf2f8d7f) Update readme.md
12
+ - [8dbe853](https://github.com/appium/ruby_lib/commit/8dbe853909a3a2691d3cc510d9751cfe8179dc76) Fix mainApp
13
+ - [347ae13](https://github.com/appium/ruby_lib/commit/347ae13cc78101875bb223fdfee97898f50a791b) Update readme.md
14
+ - [ba4d51c](https://github.com/appium/ruby_lib/commit/ba4d51c44329db8a849f59bfeedfa1eb99538d3a) Update location_rel to use center point
15
+
16
+
17
+ #### v0.19.1 2014-02-25
18
+
19
+ - [efa2e3f](https://github.com/appium/ruby_lib/commit/efa2e3feb74319a19d1fe3ef49d5a7fe3a2eb59a) Release 0.19.1
20
+ - [1aee2fc](https://github.com/appium/ruby_lib/commit/1aee2fcc5773cc92b1f83a80188f6cac50d2e206) Add android coverage cap
21
+ - [ccb213f](https://github.com/appium/ruby_lib/commit/ccb213f3866672f2be7ea526e6deb1656d497e6e) Update path logic
22
+ - [9772383](https://github.com/appium/ruby_lib/commit/97723833f1d888fa809d704801d98bdff8a3e2a4) Fix load_appium_txt relative path
23
+
24
+
1
25
  #### v0.19.0 2014-02-20
2
26
 
3
27
  - [6fd332b](https://github.com/appium/ruby_lib/commit/6fd332b1715d7b8f4b3b3c99e7ca58e5d4d01b52) Release 0.19.0
metadata CHANGED
@@ -1,125 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.21.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: 2014-02-25 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.39'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: 2.39.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.39'
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
32
  version: 2.39.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: awesome_print
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.2'
40
+ - - ">="
32
41
  - !ruby/object:Gem::Version
33
42
  version: 1.2.0
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - ~>
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.2'
50
+ - - ">="
39
51
  - !ruby/object:Gem::Version
40
52
  version: 1.2.0
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: json
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
- - - ~>
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.8'
60
+ - - ">="
46
61
  - !ruby/object:Gem::Version
47
62
  version: 1.8.1
48
63
  type: :runtime
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
- - - ~>
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.8'
70
+ - - ">="
53
71
  - !ruby/object:Gem::Version
54
72
  version: 1.8.1
55
73
  - !ruby/object:Gem::Dependency
56
74
  name: toml
57
75
  requirement: !ruby/object:Gem::Requirement
58
76
  requirements:
59
- - - ~>
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.0'
80
+ - - ">="
60
81
  - !ruby/object:Gem::Version
61
82
  version: 0.0.4
62
83
  type: :runtime
63
84
  prerelease: false
64
85
  version_requirements: !ruby/object:Gem::Requirement
65
86
  requirements:
66
- - - ~>
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.0'
90
+ - - ">="
67
91
  - !ruby/object:Gem::Version
68
92
  version: 0.0.4
69
93
  - !ruby/object:Gem::Dependency
70
94
  name: posix-spawn
71
95
  requirement: !ruby/object:Gem::Requirement
72
96
  requirements:
73
- - - ~>
97
+ - - "~>"
74
98
  - !ruby/object:Gem::Version
75
- version: 0.3.8
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ~>
99
+ version: '0.3'
100
+ - - ">="
81
101
  - !ruby/object:Gem::Version
82
102
  version: 0.3.8
83
- - !ruby/object:Gem::Dependency
84
- name: webkit_remote
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: 0.4.1
90
103
  type: :runtime
91
104
  prerelease: false
92
105
  version_requirements: !ruby/object:Gem::Requirement
93
106
  requirements:
94
- - - ~>
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.3'
110
+ - - ">="
95
111
  - !ruby/object:Gem::Version
96
- version: 0.4.1
112
+ version: 0.3.8
97
113
  - !ruby/object:Gem::Dependency
98
114
  name: rake
99
115
  requirement: !ruby/object:Gem::Requirement
100
116
  requirements:
101
- - - ~>
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '10.0'
120
+ - - ">="
102
121
  - !ruby/object:Gem::Version
103
122
  version: 10.0.4
104
123
  type: :development
105
124
  prerelease: false
106
125
  version_requirements: !ruby/object:Gem::Requirement
107
126
  requirements:
108
- - - ~>
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '10.0'
130
+ - - ">="
109
131
  - !ruby/object:Gem::Version
110
132
  version: 10.0.4
111
133
  - !ruby/object:Gem::Dependency
112
134
  name: yard
113
135
  requirement: !ruby/object:Gem::Requirement
114
136
  requirements:
115
- - - ~>
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.8'
140
+ - - ">="
116
141
  - !ruby/object:Gem::Version
117
142
  version: 0.8.7.3
118
143
  type: :development
119
144
  prerelease: false
120
145
  version_requirements: !ruby/object:Gem::Requirement
121
146
  requirements:
122
- - - ~>
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '0.8'
150
+ - - ">="
123
151
  - !ruby/object:Gem::Version
124
152
  version: 0.8.7.3
125
153
  description: Ruby library for Appium.
@@ -129,7 +157,7 @@ executables: []
129
157
  extensions: []
130
158
  extra_rdoc_files: []
131
159
  files:
132
- - .gitignore
160
+ - ".gitignore"
133
161
  - Gemfile
134
162
  - LICENSE-2.0.txt
135
163
  - Rakefile
@@ -147,8 +175,6 @@ files:
147
175
  - lib/appium_lib/android/element/textfield.rb
148
176
  - lib/appium_lib/android/helper.rb
149
177
  - lib/appium_lib/android/patch.rb
150
- - lib/appium_lib/android/webview/javascript.rb
151
- - lib/appium_lib/android/webview/webview.rb
152
178
  - lib/appium_lib/common/element/button.rb
153
179
  - lib/appium_lib/common/element/text.rb
154
180
  - lib/appium_lib/common/element/window.rb
@@ -173,17 +199,17 @@ require_paths:
173
199
  - lib
174
200
  required_ruby_version: !ruby/object:Gem::Requirement
175
201
  requirements:
176
- - - '>='
202
+ - - ">="
177
203
  - !ruby/object:Gem::Version
178
204
  version: 1.9.3
179
205
  required_rubygems_version: !ruby/object:Gem::Requirement
180
206
  requirements:
181
- - - '>='
207
+ - - ">="
182
208
  - !ruby/object:Gem::Version
183
209
  version: '0'
184
210
  requirements: []
185
211
  rubyforge_project:
186
- rubygems_version: 2.1.11
212
+ rubygems_version: 2.2.2
187
213
  signing_key:
188
214
  specification_version: 4
189
215
  summary: Ruby library for Appium
@@ -1,76 +0,0 @@
1
- # encoding: utf-8
2
- module Appium; end # fix module not defined
3
- module Android; end
4
- module Appium::Android::Webview
5
- class << self
6
- # firstEmailInput().value = 'example';
7
- # firstPasswordInput().value = 'example'
8
- # firstSubmitElement().click();
9
-
10
- # todo: prevent namespace pollution
11
- # AppiumWebview = { 'ok': function() { return 'ok'; }, 'ok2': function() { return self.ok(); } }
12
-
13
- def javascript
14
- @javascript_webview_helpers ||= <<-'JS'
15
- function firstTagWithTypeOrName(targetTag, targetType, targetName) {
16
- var inputs = document.getElementsByTagName(targetTag);
17
- var inputsLength = inputs.length;
18
- var target = null;
19
-
20
- var targetNames = [];
21
- if (targetName) targetNames = targetName.split(",");
22
-
23
- for (var i = 0; i < inputsLength; i++) {
24
- var input = inputs[i];
25
-
26
- if (targetType) {
27
- var type = input.type;
28
- var hasType = typeof type !== "undefined";
29
- if (hasType && type.trim().toLowerCase() === targetType) {
30
- target = input;
31
- break;
32
- }
33
- }
34
-
35
- // type only search will have undefined targetName.
36
- if (targetName) {
37
- var name = input.name;
38
- var hasName = typeof name !== "undefined";
39
- if (hasName && targetNames.indexOf(name.trim().toLowerCase()) !== -1) {
40
- target = input;
41
- break;
42
- }
43
- }
44
- }
45
-
46
- return target;
47
- }
48
-
49
- function firstInputWithTypeOrName(targetType, targetName) {
50
- return firstTagWithTypeOrName('input', targetType, targetName);
51
- }
52
-
53
- function firstEmailInput() {
54
- return firstInputWithTypeOrName('email', 'id,username');
55
- }
56
-
57
- function firstPasswordInput() {
58
- return firstInputWithTypeOrName('password', 'password');
59
- }
60
-
61
- // yahoo uses a submit button
62
- function firstSubmitElement() {
63
- return firstTagWithTypeOrName('button', 'submit', 'submit') ||
64
- firstTagWithTypeOrName('input', 'submit', 'submit') ||
65
- firstTagWithTypeOrName('a', 'submit', 'submit');
66
- }
67
-
68
- // yahoo authorize link
69
- // <a type="submit"
70
- function firstAuthElement() {
71
- return firstTagWithTypeOrName('a', 'submit');
72
- }
73
- JS
74
- end
75
- end
76
- end
@@ -1,105 +0,0 @@
1
- # encoding: utf-8
2
- # system requires
3
- require 'net/http'
4
-
5
- # 3rd party gems
6
- require 'rubygems'
7
- require 'json'
8
- require 'posix/spawn'
9
- require 'webkit_remote' # https://github.com/pwnall/webkit_remote/
10
-
11
- module Appium; end # fix module not defined
12
- module Android; end
13
- module Appium::Android::Webview
14
- class << self
15
- # @private
16
- def adb_cmd cmd
17
- _pid, _in, _out, _err = POSIX::Spawn::popen4 cmd, {:err => [:child, :out]}
18
- _in.close
19
-
20
- output = ''
21
-
22
- begin
23
- Process.waitpid _pid
24
- output = _out.read
25
- [_out, _err].each { |io| io.close unless io.nil? || io.closed? }
26
- rescue # no such process
27
- end
28
-
29
- output
30
- end
31
-
32
- # @private
33
- # returns nil if not found
34
- def package_to_pid package
35
- # USER PID PPID VSIZE RSS WCHAN PC NAME
36
- # use detect to return the first match
37
- ps = adb_cmd('adb shell ps').split("\r\n").detect { |l| l.split(' ').last == package }
38
- ps ? ps.split(' ')[1].to_i : nil # return pid
39
- end
40
-
41
- # @private
42
- # 1 pid may have many webviews. The path remains the same
43
- #
44
- #["00000000: 00000002 00000000 00010000 0001 01 4716 @webview_devtools_remote_1597",
45
- # "00000000: 00000003 00000000 00000000 0001 03 55080 @webview_devtools_remote_1597",
46
- # "00000000: 00000003 00000000 00000000 0001 03 55078 @webview_devtools_remote_1597"]
47
- #
48
- # returns nil if not found
49
- def pid_to_webview pid
50
- return nil if pid.nil?
51
- # Num RefCount Protocol Flags Type St Inode Path
52
- cat_proc = adb_cmd 'adb shell cat /proc/net/unix'
53
- pid_webview = "@webview_devtools_remote_#{pid}"
54
- found = cat_proc.split("\r\n").detect { |l| l.include?(pid_webview) }
55
- # must remove '@' prefix for use with adb forward command
56
- found ? found.split(' ').last.sub('@', '') : nil
57
- end
58
-
59
- # @private
60
- # connect_to_webview package: 'com.example.Package'
61
- def connect_to_webview opts={}
62
- package = opts[:package]
63
- raise 'Must provide package' unless package
64
- port = opts.fetch :port, 9000
65
-
66
- unix_socket = pid_to_webview package_to_pid package
67
- raise 'No webview found' unless unix_socket
68
- adb_cmd "adb forward tcp:#{port} localabstract:#{unix_socket}"
69
- end
70
-
71
- # @public
72
- #
73
- # ```ruby
74
- # webview = Appium::Android::Webview.attach_to_tab package: 'com.example.Package', url: 'yahoo.com/'
75
- # webview.location
76
- # webview.client
77
- # webview.client.remote_eval Appium::Android::Webview.javascript
78
- # ```
79
- #
80
- # port: is optional.
81
- #
82
- # can't be called more than once.
83
- #
84
- # returns URL of connected tab.
85
- def attach_to_tab opts={}
86
- connect_to_webview package: opts[:package]
87
- target_url = opts[:url]
88
- raise 'Must provide :url' unless target_url
89
- port = opts.fetch(:port, 9000)
90
-
91
- # webkit_remote defaults to using the last tab.
92
- # The browser may have many tabs and the last tab is not always correct.
93
- # Detect the tab by inspecting the URL.
94
- # https://github.com/pwnall/webkit_remote/blob/590bfd3ace098f2b75d1a07651f36f4392109a23/lib/webkit_remote/top_level.rb#L30
95
- browser = WebkitRemote::Browser.new host: 'localhost', port: port
96
- target_tab = browser.tabs.detect { |tab| tab.url.include?(target_url) }
97
-
98
- client = WebkitRemote::Client.new tab: target_tab, close_browser: true
99
- document_location = client.remote_eval 'document.location.toString()'
100
- client.clear_all
101
-
102
- OpenStruct.new( client: client, location: document_location )
103
- end
104
- end
105
- end