appium_lib 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmE2MWU3M2FmMDI5OWVkNzQ3Mzk5ZjAzMjdkODcxNGFiNmIzNzI1Yw==
4
+ YjQ3MTdiNzQwZmRjNTg0NDYxMTc1ODg5ODhiNjk2ZWEwZTgxNjhkMA==
5
5
  data.tar.gz: !binary |-
6
- MDdiZGM4MjAzZjU3OTQ4MTAxZjJiNjg2MTdmNzEzNjFlN2U5ZjMxMw==
6
+ YTlkOGM3YzI5ZTFlNGQzZGIxNDkxN2Y2MWE2NjVlNmU3ODBiYWE4ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDk5OWIyNjgzYzg3M2NiNmE2OGJiZmI3MDM5YTM5NDg4MmNiYTE0Nzg2YTlj
10
- MGEyZTA0NTdjZjYyYWQxMGE2ZjY4MDkyOWE1NzRkYTFjZTQ0MWU3NTcwMGI1
11
- NzAyZmQ4ODhkYzBkMmFiM2RkYzQ0MjlhNDA3NGYxNWJlOWNiNzI=
9
+ ZWFiYmY4MzIzMTc1NDE5MWZhNTIwMzY3ZjMyZGU2YzBlZjhiYTMxNzI1MTA3
10
+ Njg1MjE0ZDg0YjkwYTExNzg0OTIyYWZjMDUwMDg1OWRhZWY3YzE4YTkzNDU2
11
+ Y2VlZWEzOTliNDEyNWMwMTA3YmNmZWRlMTQxNzE4ZDU0YTc5Yjg=
12
12
  data.tar.gz: !binary |-
13
- NjU2M2Q2NWE0MWY4NTg5NTAwNzFjYzcyYjg0NjNhYzU2YTNlZDI4MTFjY2Nm
14
- YTIzMTFmZGZhMTA4YTc4MDIyZmZkMGY0ZDczZWIyMjdiZTk4ZjM5MTRlOWI1
15
- NThkMjVjZjU2MTAxODhhYTQyNmM4MTZjNDFlOTU1M2IwYjhlYjg=
13
+ ZDA0Y2UxMTg1ZDcxNzJhOWEwNmEzMjIxN2MyZDczY2UxMzgyODAxN2Q4M2Ey
14
+ MjAyODM4OTUzYTk5ZGQxNGJmMmE1NjJkNTgxZTE3MGJiOGY0NzgzMDYyYzU3
15
+ MTkzMWYwOWNmODQyZGQ5ZjBjNjE5YTA0OTQ5ZjUzZmVhMzNiN2M=
@@ -6,22 +6,9 @@ $last_driver = nil
6
6
  def self.method_missing method, *args, &block
7
7
  raise "driver is nil. called #{method}" if $last_driver == nil
8
8
 
9
- has_args = ! args.empty?
10
- has_block = ! block.nil?
11
-
12
- # method with no params
13
- if ! has_args && ! has_block
14
- $last_driver.send method
15
- # method with only arg params
16
- elsif has_args && ! has_block
17
- $last_driver.send method, *args
18
- # method with only block param
19
- elsif ! has_args && has_block
20
- $last_driver.send method, block
21
- # method with arg + block
22
- elsif has_args && has_block
23
- $last_driver.send method, *args, block
24
- end
9
+ $last_driver.respond_to?(method) ?
10
+ $last_driver.send( method, *args, &block ) :
11
+ super
25
12
  end
26
13
 
27
14
  module Appium
@@ -35,6 +35,19 @@ module Appium::Common
35
35
  @driver.navigate.back
36
36
  end
37
37
 
38
+ # For Sauce Labs reporting
39
+ def session_id
40
+ @driver.session_id
41
+ end
42
+
43
+ def sauce_username
44
+ @sauce_username
45
+ end
46
+
47
+ def sauce_access_key
48
+ @sauce_access_key
49
+ end
50
+
38
51
  def xpath xpath_str
39
52
  find_element :xpath, xpath_str
40
53
  end
@@ -137,4 +150,12 @@ module Appium::Common
137
150
  def get_source
138
151
  JSON.parse(@driver.page_source)
139
152
  end
153
+
154
+ def find_name name
155
+ find_element :name, name
156
+ end
157
+
158
+ def find_names name
159
+ find_elements :name, name
160
+ end
140
161
  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.3.0' unless defined? ::Appium::VERSION
5
- DATE = '2013-04-25' unless defined? ::Appium::DATE
4
+ VERSION = '0.3.1' unless defined? ::Appium::VERSION
5
+ DATE = '2013-04-26' unless defined? ::Appium::DATE
6
6
  end
@@ -32,6 +32,8 @@ module Appium
32
32
  require 'android/element/textfield'
33
33
 
34
34
  class Driver
35
+ @@loaded = false
36
+
35
37
  def initialize opts={}
36
38
  opts = {} if opts.nil?
37
39
  # Path to the .apk, .app or .app.zip.
@@ -71,12 +73,27 @@ module Appium
71
73
  # load Android specific methods
72
74
  extend Appium::Android
73
75
  else
76
+ @ios_js = [] # used to keep track of loaded JavaScript on iOS
74
77
  # load iOS specific methods
75
78
  extend Appium::Ios
76
79
  end
77
80
 
78
81
  # Save global reference to last created Appium driver for top level methods.
79
82
  $last_driver = self
83
+
84
+ # Promote exactly once the first time the driver is created.
85
+ # Subsequent drivers do not trigger promotion.
86
+ unless @@loaded
87
+ @@loaded = true
88
+ # Promote Appium driver methods to Object instance methods.
89
+ $last_driver.public_methods(false).each do | m |
90
+ Object.class_eval do
91
+ define_method m do | *args, &block |
92
+ $last_driver.send m, *args, &block
93
+ end
94
+ end
95
+ end
96
+ end
80
97
  end # def initialize
81
98
 
82
99
  # WebDriver capabilities. Must be valid for Sauce to work.
@@ -19,6 +19,55 @@ module Appium::Ios
19
19
  Android name = iOS name & label
20
20
  Android text = iOS value
21
21
  =end
22
+ def ios_js_loaded? method_name
23
+ @ios_js.include? method_name
24
+ end
25
+
26
+ def ios_js_load method_name
27
+ @ios_js.push method_name
28
+ end
29
+
30
+ def name_contains_js
31
+ # execute_script 'au.mainApp.getNameContains("sign")'
32
+ # execute_script 'au.mainApp.getNameContains("zzz")'
33
+ <<-JS
34
+ UIAElement.prototype.getNameContains = function(targetName) {
35
+ var target = UIATarget.localTarget();
36
+ target.pushTimeout(0);
37
+ var search = "name contains[c] '" + targetName + "' || label contains[c] '" + targetName + "'";
38
+ var searchElements = function(element) {
39
+ var children = element.elements();
40
+ var result = children.firstWithPredicate(search);
41
+ if (result.type() !== 'UIAElementNil') {
42
+ return result;
43
+ }
44
+
45
+ for ( var a = 0, len = children.length; a < len; a++) {
46
+ result = searchElements(children[a]);
47
+ if (result.type() !== 'UIAElementNil') {
48
+ return result;
49
+ }
50
+ }
51
+
52
+ return result;
53
+ };
54
+ var result = searchElements(this);
55
+ target.popTimeout();
56
+
57
+ if (result.type() === 'UIAElementNil') {
58
+ return {
59
+ status: 7,
60
+ value: {'message': 'An element could not be located on the page using the given search parameters.'}
61
+ };
62
+ }
63
+
64
+ return {
65
+ status: 0,
66
+ value: {ELEMENT: au.getId(result)}
67
+ };
68
+ };
69
+ JS
70
+ end
22
71
 
23
72
  # returnElems requires a wrapped $(element).
24
73
  # set to empty array when length is zero to prevent hang.
@@ -38,7 +87,7 @@ module Appium::Ios
38
87
  #
39
88
  # single element length is undefined when found and 0 when not found.
40
89
  def first_ele_js predicate
41
- %Q(
90
+ <<-JS
42
91
  function isNil( a ) {
43
92
  return a.type() === 'UIAElementNil';
44
93
  }
@@ -84,11 +133,11 @@ module Appium::Ios
84
133
  }
85
134
 
86
135
  run();
87
- )
136
+ JS
88
137
  end
89
138
 
90
139
  def all_ele_js predicate
91
- %Q(
140
+ <<-JS
92
141
  var w = au.mainWindow;
93
142
  var search = "#{predicate}";
94
143
  var a = w.elements().withPredicate(search).toArray();
@@ -98,7 +147,7 @@ module Appium::Ios
98
147
  }
99
148
 
100
149
  au._returnElems($(a));
101
- )
150
+ JS
102
151
  end
103
152
 
104
153
  # Return the first element matching text.
@@ -149,9 +198,12 @@ module Appium::Ios
149
198
  # @param name [String] the name to search for
150
199
  # @return [Element] the first matching element
151
200
  def name name
152
- js = first_ele_js "name contains[c] '#{name}' || label contains[c] '#{name}'"
201
+ unless ios_js_loaded? 'name_contains_js'
202
+ execute_script name_contains_js
203
+ ios_js_load 'name_contains_js'
204
+ end
153
205
 
154
- execute_script(js).first
206
+ execute_script %(au.mainApp.getNameContains("#{name}"))
155
207
  end
156
208
 
157
209
  # Return all elements matching name.
@@ -1,3 +1,40 @@
1
+ #### v0.3.0 2013-04-25
2
+
3
+ - [e08e88c](https://github.com/appium/ruby_lib/commit/e08e88c40cc56e132c5db18d9d5862028861d5f2) Release 0.3.0
4
+ - [3f4dd63](https://github.com/appium/ruby_lib/commit/3f4dd63ab2ab2e97b457bb188a347af6c74bc7df) Update code style
5
+ - [9bbb17e](https://github.com/appium/ruby_lib/commit/9bbb17e4079c7db1c033284c3120611f11f33656) Update readme.md
6
+ - [354bf19](https://github.com/appium/ruby_lib/commit/354bf19090ca6b1a7812d067321452094f7a62c0) Add new usage example
7
+ - [9668450](https://github.com/appium/ruby_lib/commit/96684503b091af581a78067342106feef5769a92) Restore top level methods
8
+ - [b095c4a](https://github.com/appium/ruby_lib/commit/b095c4a94109c508fc286801d957e4535e27462d) Rewrite as a real lib
9
+ - [71628ff](https://github.com/appium/ruby_lib/commit/71628ff13fc84c3b15f0dc3986a75bd3fcb7a28e) Fix page for iOS
10
+ - [fce0d67](https://github.com/appium/ruby_lib/commit/fce0d676cb78582703934872a0256c55ad55d225) Add force encoding check
11
+ - [aed2607](https://github.com/appium/ruby_lib/commit/aed26079c25ee2f80c8a1462dde7d589d30e014b) Raise NoSuchElementError on find
12
+ - [82dc953](https://github.com/appium/ruby_lib/commit/82dc953a302fc4505d6c7c2121da0ccbe71e053a) Add webview support to find
13
+ - [151edde](https://github.com/appium/ruby_lib/commit/151edde563bb907b07c7896794ecbb81568c3e29) Define no args page for iOS
14
+ - [b3227f7](https://github.com/appium/ruby_lib/commit/b3227f73175697782c5dbc8f62ad911fcae88965) Quote button name when string
15
+ - [0c0073d](https://github.com/appium/ruby_lib/commit/0c0073d0785ff64606c7887ec4eb83a8bcc5cafd) Add grid and relative
16
+ - [3b87251](https://github.com/appium/ruby_lib/commit/3b87251d9e749590873c1bb118c88dd4b8fdaea0) Add note about secure tag on Android
17
+ - [494f0e3](https://github.com/appium/ruby_lib/commit/494f0e39d9b1ebbafd731b4d311e4cc1cee02266) Add window mapping for Android
18
+ - [e4d63a5](https://github.com/appium/ruby_lib/commit/e4d63a569c6fede034a1fd411ba9047327389063) Replace classNameMatches with className
19
+ - [dd82100](https://github.com/appium/ruby_lib/commit/dd821001ee333801a36f2b5c01e4793e47fd037e) Fix find_eles_attr
20
+ - [de7a1bc](https://github.com/appium/ruby_lib/commit/de7a1bc1112aa3d1930647738d85ae54270685d2) Improve webdriver debug messages
21
+ - [dff41da](https://github.com/appium/ruby_lib/commit/dff41dae4a0d67200336b3daa677ab73157c0464) Better webdriver debug messages
22
+ - [d2ca728](https://github.com/appium/ruby_lib/commit/d2ca72880c9bdfb853a5dcd63e3db16fa03d3f1d) Use textContains to fetch first element only
23
+ - [1cbb69d](https://github.com/appium/ruby_lib/commit/1cbb69d8b9b69cdacfdfef663ab8ff31d506ba50) Check for empty app path
24
+ - [427e105](https://github.com/appium/ruby_lib/commit/427e105be7865c5a637e62fb597cc034b4cda2ad) Fix format
25
+ - [40cd10b](https://github.com/appium/ruby_lib/commit/40cd10bf72a080a0a34f43d189befab1b1f953e4) Update get_inspect
26
+ - [bc1cdb1](https://github.com/appium/ruby_lib/commit/bc1cdb120ccef4598333838cfaf35c54d84ad79a) Add find_eles_attr
27
+ - [e89f8bd](https://github.com/appium/ruby_lib/commit/e89f8bdad8919471ae12c11343b82c2d04d88027) Use XPath last()
28
+ - [133cf98](https://github.com/appium/ruby_lib/commit/133cf98bd27c26d1a5438bdf4534149f0f8aef89) Add xpath, xpaths
29
+ - [435eac0](https://github.com/appium/ruby_lib/commit/435eac0bd8020dd5fc30a9ae163f72ab4fda1565) Fix name
30
+ - [050734f](https://github.com/appium/ruby_lib/commit/050734f7a64e8d9386b5c2e2ccb0ce653f816437) Update first_ele to use XPath #15
31
+ - [f89dcc3](https://github.com/appium/ruby_lib/commit/f89dcc361b8c6762cad541fc9b5a2e1955b1cd27) Update ele_index to use XPath #15
32
+ - [763d086](https://github.com/appium/ruby_lib/commit/763d0862135bf9e06ad177c9e3e20a83819b1775) Use mobile method
33
+ - [09035ab](https://github.com/appium/ruby_lib/commit/09035ab053df980baf43b8d1128f68fe52df37a4) Remove old comment
34
+ - [2d07ed0](https://github.com/appium/ruby_lib/commit/2d07ed0d5868c734168b31fb47881eaa4c74af1c) Raise instead of puts
35
+ - [d904c0f](https://github.com/appium/ruby_lib/commit/d904c0f83cc6212f7682c3d15123f5db9a380312) Update release notes
36
+
37
+
1
38
  #### v0.0.30 2013-04-16
2
39
 
3
40
  - [6d65a9c](https://github.com/appium/ruby_lib/commit/6d65a9c2895b1b66556b12fee4fc9649f558ede1) Release 0.0.30
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.3.0
4
+ version: 0.3.1
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-04-25 00:00:00.000000000 Z
11
+ date: 2013-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver