calabash-cucumber 0.9.165 → 0.9.166
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 +4 -4
- data/calabash-cucumber.gemspec +1 -1
- data/lib/calabash-cucumber/core.rb +41 -18
- data/lib/calabash-cucumber/date_picker.rb +26 -8
- data/lib/calabash-cucumber/http_helpers.rb +2 -2
- data/lib/calabash-cucumber/keyboard_helpers.rb +33 -11
- data/lib/calabash-cucumber/map.rb +96 -1
- data/lib/calabash-cucumber/operations.rb +55 -4
- data/lib/calabash-cucumber/uia.rb +8 -1
- data/lib/calabash-cucumber/version.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63d73b5e63940ad25b53c4d541e86128843787de
|
|
4
|
+
data.tar.gz: 0e2c58df0c1137f892fb44ca5efecea534e40a17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 32cafe39cab410dd13ce6865266c39d04925db2d6e86f2504fb211b69f09fac5df01129327b845caaf9c86b76996f345a0dfff902fe74da9ed0b201db2dffd2b
|
|
7
|
+
data.tar.gz: c6fe8af54e3219a32d6d2811de574bc90e4c0d7201a896103c8215a4a4f81450ba402a9917ccad71696564fa4aeb900d3a8d996602ad64700489eaa5fe85e49f
|
data/calabash-cucumber.gemspec
CHANGED
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
s.add_dependency( "geocoder", "~>1.1.8")
|
|
27
27
|
s.add_dependency( "httpclient","~> 2.3.3")
|
|
28
28
|
s.add_dependency( "bundler", "~> 1.1")
|
|
29
|
-
s.add_dependency( "run_loop", "~> 0.1.
|
|
29
|
+
s.add_dependency( "run_loop", "~> 0.1.2" )
|
|
30
30
|
s.add_dependency( "awesome_print")
|
|
31
31
|
s.add_dependency( "xamarin-test-cloud", "~> 0.9.27")
|
|
32
32
|
|
|
@@ -39,8 +39,19 @@ module Calabash
|
|
|
39
39
|
map(uiquery, :query, *args)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# causes all views matched by the +query+ to briefly change colors making
|
|
43
|
+
# them visually identifiable.
|
|
44
|
+
#
|
|
45
|
+
# returns <tt>[]</tt> if no views are matched
|
|
46
|
+
#
|
|
47
|
+
# if there are matching views, returns an array of that contains the
|
|
48
|
+
# result of calling the objc selector +description+ on each matching view.
|
|
49
|
+
#
|
|
50
|
+
# NB: the +args+ argument is ignored and should be deprecated
|
|
42
51
|
def flash(uiquery, *args)
|
|
43
|
-
|
|
52
|
+
# todo deprecate the *args argument in the flash method
|
|
53
|
+
# todo :flash operation should return views as JSON objects
|
|
54
|
+
map(uiquery, :flash, *args).compact
|
|
44
55
|
end
|
|
45
56
|
|
|
46
57
|
def server_version
|
|
@@ -100,7 +111,6 @@ module Calabash
|
|
|
100
111
|
launcher.actions.pinch(in_out.to_sym,options)
|
|
101
112
|
end
|
|
102
113
|
|
|
103
|
-
|
|
104
114
|
def cell_swipe(options={})
|
|
105
115
|
if uia_available?
|
|
106
116
|
raise 'cell_swipe not supported with instruments, simply use swipe with a query that matches the cell'
|
|
@@ -110,15 +120,15 @@ module Calabash
|
|
|
110
120
|
|
|
111
121
|
def scroll(uiquery, direction)
|
|
112
122
|
views_touched=map(uiquery, :scroll, direction)
|
|
113
|
-
|
|
123
|
+
msg = "could not find view to scroll: '#{uiquery}', args: #{direction}"
|
|
124
|
+
assert_map_results(views_touched, msg)
|
|
114
125
|
views_touched
|
|
115
126
|
end
|
|
116
127
|
|
|
117
128
|
def scroll_to_row(uiquery, number)
|
|
118
129
|
views_touched=map(uiquery, :scrollToRow, number)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
end
|
|
130
|
+
msg = "unable to scroll: '#{uiquery}' to: #{number}"
|
|
131
|
+
assert_map_results(views_touched, msg)
|
|
122
132
|
views_touched
|
|
123
133
|
end
|
|
124
134
|
|
|
@@ -144,10 +154,8 @@ module Calabash
|
|
|
144
154
|
args << options[:animate]
|
|
145
155
|
end
|
|
146
156
|
views_touched=map(uiquery, :scrollToRow, row.to_i, sec.to_i, *args)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
screenshot_and_raise "Unable to scroll: '#{uiquery}' to: #{options}"
|
|
150
|
-
end
|
|
157
|
+
msg = "unable to scroll: '#{uiquery}' to '#{options}'"
|
|
158
|
+
assert_map_results(views_touched, msg)
|
|
151
159
|
views_touched
|
|
152
160
|
end
|
|
153
161
|
|
|
@@ -155,6 +163,10 @@ module Calabash
|
|
|
155
163
|
def scroll_to_row_with_mark(row_id, options={:query => 'tableView',
|
|
156
164
|
:scroll_position => :middle,
|
|
157
165
|
:animate => true})
|
|
166
|
+
if row_id.nil?
|
|
167
|
+
screenshot_and_raise 'row_id argument cannot be nil'
|
|
168
|
+
end
|
|
169
|
+
|
|
158
170
|
uiquery = options[:query] || 'tableView'
|
|
159
171
|
|
|
160
172
|
args = []
|
|
@@ -168,11 +180,8 @@ module Calabash
|
|
|
168
180
|
end
|
|
169
181
|
|
|
170
182
|
views_touched=map(uiquery, :scrollToRowWithMark, row_id, *args)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
msg = options[:failed_message] || "Unable to scroll: '#{uiquery}' to: #{options}"
|
|
174
|
-
screenshot_and_raise msg
|
|
175
|
-
end
|
|
183
|
+
msg = options[:failed_message] || "Unable to scroll: '#{uiquery}' to: #{options}"
|
|
184
|
+
assert_map_results(views_touched, msg)
|
|
176
185
|
views_touched
|
|
177
186
|
end
|
|
178
187
|
|
|
@@ -268,7 +277,6 @@ module Calabash
|
|
|
268
277
|
texts
|
|
269
278
|
end
|
|
270
279
|
|
|
271
|
-
|
|
272
280
|
def backdoor(sel, arg)
|
|
273
281
|
json = {
|
|
274
282
|
:selector => sel,
|
|
@@ -293,6 +301,21 @@ module Calabash
|
|
|
293
301
|
end
|
|
294
302
|
end
|
|
295
303
|
|
|
304
|
+
def server_debug_level
|
|
305
|
+
_debug_level_response(http(:method => :get, :path => 'debug'))
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def set_server_debug_level(level)
|
|
309
|
+
_debug_level_response(http({:method => :post, :path => 'debug'}, {:level => level}))
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def _debug_level_response(json)
|
|
313
|
+
res = JSON.parse(json)
|
|
314
|
+
if res['outcome'] != 'SUCCESS'
|
|
315
|
+
screenshot_and_raise "debug_level #{json} failed because: #{res['reason']}\n#{res['details']}"
|
|
316
|
+
end
|
|
317
|
+
res['results'].first
|
|
318
|
+
end
|
|
296
319
|
## args :app for device bundle id, for sim path to app
|
|
297
320
|
##
|
|
298
321
|
def start_test_server_in_background(args={})
|
|
@@ -312,7 +335,6 @@ module Calabash
|
|
|
312
335
|
stop_test_server
|
|
313
336
|
end
|
|
314
337
|
|
|
315
|
-
|
|
316
338
|
def console_attach
|
|
317
339
|
# setting the @calabash_launcher here for backward compatibility
|
|
318
340
|
@calabash_launcher = launcher.attach
|
|
@@ -327,7 +349,8 @@ module Calabash
|
|
|
327
349
|
uiquery, options = extract_query_and_options(uiquery, options)
|
|
328
350
|
views_touched = launcher.actions.send(action, options)
|
|
329
351
|
unless uiquery.nil?
|
|
330
|
-
|
|
352
|
+
msg = "#{action} could not find view: '#{uiquery}', args: #{options}"
|
|
353
|
+
assert_map_results(views_touched, msg)
|
|
331
354
|
end
|
|
332
355
|
views_touched
|
|
333
356
|
end
|
|
@@ -122,12 +122,33 @@ module Calabash
|
|
|
122
122
|
args
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
#
|
|
127
|
-
#
|
|
125
|
+
|
|
126
|
+
# sets the date and time on picker identified by <tt>options[:picker_id]</tt>
|
|
127
|
+
# using the DateTime +target_dt+
|
|
128
|
+
#
|
|
129
|
+
# valid options are:
|
|
130
|
+
#
|
|
131
|
+
# :animate - animate the change - default is +true+
|
|
132
|
+
# :picker_id - the id (or mark) of the date picker - default is +nil+ which
|
|
133
|
+
# will target the first visible date picker
|
|
134
|
+
# :notify_targets - notify all objc targets that the date picker has changed
|
|
135
|
+
# default is +true+
|
|
136
|
+
#
|
|
137
|
+
# when <tt>:notify_targets = true</tt> this operation iterates through the
|
|
138
|
+
# target/action pairs on the objc +UIDatePicker+ instance and calls
|
|
139
|
+
# <tt>performSelector:<action> object:<target></tt> to simulate a +UIEvent+
|
|
140
|
+
#
|
|
141
|
+
# raises an error if
|
|
142
|
+
# * no UIDatePicker can be found
|
|
143
|
+
# * the target date is greater than the picker's maximum date
|
|
144
|
+
# * the target date is less than the picker's minimum date
|
|
145
|
+
# * the target date is not a DateTime object
|
|
128
146
|
def picker_set_date_time (target_dt, options = {:animate => true,
|
|
129
147
|
:picker_id => nil,
|
|
130
148
|
:notify_targets => true})
|
|
149
|
+
unless target_dt.is_a?(DateTime)
|
|
150
|
+
raise "target_dt must be a DateTime but found '#{target_dt.class}'"
|
|
151
|
+
end
|
|
131
152
|
|
|
132
153
|
picker_id = options == nil ? nil : options[:picker_id]
|
|
133
154
|
|
|
@@ -142,11 +163,8 @@ module Calabash
|
|
|
142
163
|
query_str = query_string_for_picker picker_id
|
|
143
164
|
|
|
144
165
|
views_touched = map(query_str, :changeDatePickerDate, target_str, fmt_str, *args)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
screenshot_and_raise "could not change date on picker to '#{target_dt}' using query '#{query_str}' with options '#{options}'"
|
|
148
|
-
end
|
|
149
|
-
|
|
166
|
+
msg = "could not change date on picker to '#{target_dt}' using query '#{query_str}' with options '#{options}'"
|
|
167
|
+
assert_map_results(views_touched,msg)
|
|
150
168
|
views_touched
|
|
151
169
|
end
|
|
152
170
|
end
|
|
@@ -92,8 +92,8 @@ module Calabash
|
|
|
92
92
|
def init_request(options={})
|
|
93
93
|
http = HTTPClient.new
|
|
94
94
|
http.connect_timeout = 30
|
|
95
|
-
http.send_timeout =
|
|
96
|
-
http.receive_timeout =
|
|
95
|
+
http.send_timeout = 120
|
|
96
|
+
http.receive_timeout = 120
|
|
97
97
|
if options[:debug] || (ENV['DEBUG_HTTP'] == '1' && options[:debug] != false)
|
|
98
98
|
http.debug_dev = $stdout
|
|
99
99
|
end
|
|
@@ -230,14 +230,15 @@ module Calabash
|
|
|
230
230
|
code = UIA_SUPPORTED_CHARS[chr]
|
|
231
231
|
|
|
232
232
|
unless code
|
|
233
|
-
raise "
|
|
233
|
+
raise "typing character '#{chr}' is not yet supported when running with Instruments"
|
|
234
234
|
end
|
|
235
235
|
|
|
236
|
-
# on iOS 6, the char code is _not_ \b
|
|
237
|
-
#
|
|
238
|
-
#
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
# on iOS 6, the Delete char code is _not_ \b
|
|
237
|
+
# on iOS 7, the Delete char code is \b on non-numeric keyboards
|
|
238
|
+
# on numeric keyboards, it is actually a button on the
|
|
239
|
+
# keyboard and not a key
|
|
240
|
+
if code.eql?(UIA_SUPPORTED_CHARS['Delete'])
|
|
241
|
+
uia("uia.keyboard().elements().firstWithName('Delete').tap()")
|
|
241
242
|
else
|
|
242
243
|
uia_type_string(code)
|
|
243
244
|
end
|
|
@@ -274,7 +275,7 @@ module Calabash
|
|
|
274
275
|
def keyboard_enter_text(text)
|
|
275
276
|
_ensure_can_enter_text
|
|
276
277
|
if uia_available?
|
|
277
|
-
text_before =
|
|
278
|
+
text_before = _text_from_first_responder()
|
|
278
279
|
uia_type_string(text, text_before)
|
|
279
280
|
else
|
|
280
281
|
text.each_char do |ch|
|
|
@@ -287,7 +288,6 @@ module Calabash
|
|
|
287
288
|
end
|
|
288
289
|
end
|
|
289
290
|
|
|
290
|
-
|
|
291
291
|
# touches the keyboard +action+ key
|
|
292
292
|
#
|
|
293
293
|
# the +action+ key depends on the keyboard. some examples include:
|
|
@@ -301,7 +301,7 @@ module Calabash
|
|
|
301
301
|
# raises an error if the key cannot be entered
|
|
302
302
|
def tap_keyboard_action_key
|
|
303
303
|
if uia_available?
|
|
304
|
-
uia_type_string '\n'
|
|
304
|
+
uia_type_string '\n', '', false
|
|
305
305
|
else
|
|
306
306
|
keyboard_enter_char 'Return'
|
|
307
307
|
end
|
|
@@ -700,8 +700,7 @@ module Calabash
|
|
|
700
700
|
unless uia_available?
|
|
701
701
|
screenshot_and_raise 'only available if there is a run_loop i.e. the app was launched with Instruments'
|
|
702
702
|
end
|
|
703
|
-
|
|
704
|
-
res = uia('UIATarget.localTarget().frontMostApp().keyboard()')['value']
|
|
703
|
+
res = uia_query_windows(:keyboard)
|
|
705
704
|
not res.eql?(':nil')
|
|
706
705
|
end
|
|
707
706
|
|
|
@@ -730,6 +729,29 @@ module Calabash
|
|
|
730
729
|
end
|
|
731
730
|
end
|
|
732
731
|
|
|
732
|
+
|
|
733
|
+
private
|
|
734
|
+
|
|
735
|
+
# returns the the text in the first responder
|
|
736
|
+
#
|
|
737
|
+
# the first responder will be the +UITextField+ or +UITextView+ instance
|
|
738
|
+
# that is associated with the visible keyboard.
|
|
739
|
+
#
|
|
740
|
+
# returns +nil+ if there no +textField+ or +testView+ is found to be
|
|
741
|
+
# the first responder. it is extremely unlikely that this will happen.
|
|
742
|
+
#
|
|
743
|
+
# raises an exception if there is no visible keyboard
|
|
744
|
+
def _text_from_first_responder
|
|
745
|
+
raise 'there must be a visible keyboard' unless keyboard_visible?
|
|
746
|
+
|
|
747
|
+
['textField', 'textView'].each do |ui_class|
|
|
748
|
+
res = query("#{ui_class} isFirstResponder:1", :text)
|
|
749
|
+
return res.first unless res.empty?
|
|
750
|
+
end
|
|
751
|
+
#noinspection RubyUnnecessaryReturnStatement
|
|
752
|
+
return nil
|
|
753
|
+
end
|
|
754
|
+
|
|
733
755
|
end
|
|
734
756
|
end
|
|
735
757
|
end
|
|
@@ -4,10 +4,63 @@ module Calabash
|
|
|
4
4
|
module Cucumber
|
|
5
5
|
module Map #=> Connection
|
|
6
6
|
|
|
7
|
+
# returns an array of views matched by the +query+ or the result of
|
|
8
|
+
# performing the Objective-C sequence defined by the +method_name+ and
|
|
9
|
+
# +method_args+ on all the views matched by the +query+
|
|
10
|
+
#
|
|
11
|
+
# the query language is documented here: https://github.com/calabash/calabash-ios/wiki
|
|
12
|
+
#
|
|
13
|
+
# returns a JSON representation of each view that is matched
|
|
14
|
+
#
|
|
15
|
+
# when the +method_name+ is a calabash operation, returns an array that
|
|
16
|
+
# contains the result of calling the objc selector +description+ on each
|
|
17
|
+
# matched view. these are examples of calabash operations: +:flash+,
|
|
18
|
+
# +:scrollToRowWithMark+, +:changeDatePickerDate+.
|
|
7
19
|
def map(query, method_name, *method_args)
|
|
8
|
-
|
|
20
|
+
#todo calabash operations should return 'views touched' in JSON format
|
|
21
|
+
raw_map(query, method_name, *method_args)['results']
|
|
9
22
|
end
|
|
10
23
|
|
|
24
|
+
# returns a JSON object the represents the result of performing an http
|
|
25
|
+
# query against the calabash server.
|
|
26
|
+
#
|
|
27
|
+
# gem users should _not_ call this method directly; call +map+ instead.
|
|
28
|
+
#
|
|
29
|
+
# raises an error and takes a screenshot if the value of the +outcome+ key
|
|
30
|
+
# is _not_ 'SUCCESS'
|
|
31
|
+
#
|
|
32
|
+
# the JSON object contains the following keys:
|
|
33
|
+
#
|
|
34
|
+
# +outcome+ => indicates the success or failure of the query
|
|
35
|
+
#
|
|
36
|
+
# +status_bar_orientation+ => the orientation of the status bar
|
|
37
|
+
#
|
|
38
|
+
# +results+ => views matched by the +query+ or the result of
|
|
39
|
+
# performing the Objective-C selector sequence defined by
|
|
40
|
+
# the +method_name+ with arguments defined in
|
|
41
|
+
# +method_args+ on all views matched by the +query+
|
|
42
|
+
#
|
|
43
|
+
# the query language is documented here: https://github.com/calabash/calabash-ios/wiki
|
|
44
|
+
#
|
|
45
|
+
# here are some examples that clarify how the +method_name+ and +method_args+
|
|
46
|
+
# influence the value of the +results+ key
|
|
47
|
+
#
|
|
48
|
+
# simple examples:
|
|
49
|
+
#
|
|
50
|
+
# raw_map('label')['result'] #=> [ all visible UILabels ]
|
|
51
|
+
# raw_map('label', :text) #=> [ the 'text' of all visible UILabels ]
|
|
52
|
+
#
|
|
53
|
+
# example of calling a selector with arguments:
|
|
54
|
+
#
|
|
55
|
+
# <tt>raw_map("tableView marked:'cheeses'", {'numberOfRowsInSection' => 0})) =></tt>
|
|
56
|
+
# <tt>[ the number of rows in the first section of the 'cheeses' table ]</tt>
|
|
57
|
+
#
|
|
58
|
+
# example of calling a selector on view to return an object and then calling
|
|
59
|
+
# another selector on the returned object:
|
|
60
|
+
#
|
|
61
|
+
# <tt>raw_map("pickerView marked:'cheeses'", :delegate, [{pickerView:nil},{titleForRow:1},{forComponent:0}]) =></tt>
|
|
62
|
+
# objc call: <tt>[[pickerView delegate] pickerView:nil titleForRow:1 forComponent:0] =></tt>
|
|
63
|
+
# <tt>['French']</tt>
|
|
11
64
|
def raw_map(query, method_name, *method_args)
|
|
12
65
|
operation_map = {
|
|
13
66
|
:method_name => method_name,
|
|
@@ -23,6 +76,48 @@ module Calabash
|
|
|
23
76
|
res
|
|
24
77
|
end
|
|
25
78
|
|
|
79
|
+
# asserts the result of a calabash +map+ call and raises an error with
|
|
80
|
+
# +msg+ if no valid results are found.
|
|
81
|
+
#
|
|
82
|
+
# casual gem users should never need to call this method; this is a
|
|
83
|
+
# convenience method for gem maintainers.
|
|
84
|
+
#
|
|
85
|
+
# raises an error if +map_results+:
|
|
86
|
+
#
|
|
87
|
+
# is an empty list #=> []
|
|
88
|
+
# contains a '<VOID>' string #=> [ "<VOID>" ]
|
|
89
|
+
# contains '*****' string #=> [ "*****" ]
|
|
90
|
+
# contains a single nil #=> [ nil ]
|
|
91
|
+
#
|
|
92
|
+
# when evaluating whether a +map+ call is successful it is important to
|
|
93
|
+
# note that sometimes a <tt>[ nil ]</tt> or <tt>[nil, <val>, nil]</tt> is
|
|
94
|
+
# a valid result.
|
|
95
|
+
#
|
|
96
|
+
# consider a controller with 3 labels:
|
|
97
|
+
#
|
|
98
|
+
# label @ index 0 has text "foo"
|
|
99
|
+
# label @ index 1 has text nil (the [label text] => nil)
|
|
100
|
+
# label @ index 2 has text "bar"
|
|
101
|
+
#
|
|
102
|
+
# map('label', :text) => ['foo', nil, 'bar']
|
|
103
|
+
# map('label index:1', :text) => [nil]
|
|
104
|
+
#
|
|
105
|
+
# in other cases, <tt>[ nil ]</tt> should be treated as an invalid result
|
|
106
|
+
#
|
|
107
|
+
# # invalid
|
|
108
|
+
# > mark = 'mark does not exist'
|
|
109
|
+
# > map('tableView', :scrollToRowWithMark, mark, args) => [ nil ]
|
|
110
|
+
#
|
|
111
|
+
# here a <tt>[ nil ]</tt> should be considered invalid because the
|
|
112
|
+
# the operation could not be performed because there is not row that
|
|
113
|
+
# matches +mark+
|
|
114
|
+
def assert_map_results(map_results, msg)
|
|
115
|
+
compact = map_results.compact
|
|
116
|
+
if compact.empty? or compact.member? '<VOID>' or compact.member? '*****'
|
|
117
|
+
screenshot_and_raise msg
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
26
121
|
end
|
|
27
122
|
end
|
|
28
123
|
end
|
|
@@ -65,22 +65,73 @@ module Calabash
|
|
|
65
65
|
query(q).map { |e| e['html'] }
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
+
# sets the text value of the views matched by +uiquery+ to +txt+
|
|
69
|
+
#
|
|
70
|
+
# @deprecated since 0.9.145
|
|
71
|
+
#
|
|
72
|
+
# we have stopped testing this method. you have been warned.
|
|
73
|
+
#
|
|
74
|
+
# * to enter text using the native keyboard use 'keyboard_enter_text'
|
|
75
|
+
# * to delete text use 'keyboard_enter_text('Delete')"
|
|
76
|
+
# * to clear a text field or text view:
|
|
77
|
+
# - RECOMMENDED: use queries and touches to replicate what the user would do
|
|
78
|
+
# - for text fields, implement a clear text button and touch it
|
|
79
|
+
# - for text views, use touches to reveal text editing popup
|
|
80
|
+
# see https://github.com/calabash/calabash-ios/issues/151
|
|
81
|
+
# - use 'clear_text'
|
|
82
|
+
# https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API
|
|
83
|
+
#
|
|
84
|
+
# raises an error if the +uiquery+ finds no matching queries or finds
|
|
85
|
+
# a view that does not respond to the objc selector 'setText'
|
|
68
86
|
def set_text(uiquery, txt)
|
|
69
|
-
msgs = ["'set_text'
|
|
87
|
+
msgs = ["'set_text' is deprecated and its behavior is now unpredictable",
|
|
70
88
|
"* to enter text using the native keyboard use 'keyboard_enter_text'",
|
|
71
|
-
"* to
|
|
89
|
+
"* to delete text use 'keyboard_enter_text('Delete')",
|
|
90
|
+
'* to clear a text field or text view:',
|
|
91
|
+
' - RECOMMENDED: use queries and touches to replicate what the user would do',
|
|
92
|
+
' * for text fields, implement a clear text button and touch it',
|
|
93
|
+
' * for text views, use touches to reveal text editing popup',
|
|
94
|
+
' see https://github.com/calabash/calabash-ios/issues/151',
|
|
95
|
+
" - use 'clear_text'",
|
|
72
96
|
'https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API']
|
|
73
97
|
msg = msgs.join("\n")
|
|
74
98
|
_deprecated('0.9.145', msg, :warn)
|
|
75
99
|
|
|
76
100
|
text_fields_modified = map(uiquery, :setText, txt)
|
|
77
|
-
|
|
101
|
+
|
|
102
|
+
msg = "query '#{uiquery}' returned no matching views that respond to 'setText'"
|
|
103
|
+
assert_map_results(text_fields_modified, msg)
|
|
78
104
|
text_fields_modified
|
|
79
105
|
end
|
|
80
106
|
|
|
107
|
+
# sets the text value of the views matched by +uiquery+ to <tt>''</tt>
|
|
108
|
+
# (the empty string)
|
|
109
|
+
#
|
|
110
|
+
# using this sparingly and with caution
|
|
111
|
+
#
|
|
112
|
+
#
|
|
113
|
+
# it is recommended that you instead do some combination of the following
|
|
114
|
+
#
|
|
115
|
+
# * use queries and touches to replicate with the user would
|
|
116
|
+
# - for text fields, implement a clear text button and touch it
|
|
117
|
+
# - for text views, use touches to reveal text editing popup
|
|
118
|
+
# see https://github.com/calabash/calabash-ios/issues/151
|
|
119
|
+
#
|
|
120
|
+
# https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API
|
|
121
|
+
#
|
|
122
|
+
# raises an error if the +uiquery+ finds no matching queries or finds
|
|
123
|
+
# a _single_ view that does not respond to the objc selector 'setText'
|
|
124
|
+
#
|
|
125
|
+
# IMPORTANT
|
|
126
|
+
# calling:
|
|
127
|
+
#
|
|
128
|
+
# > clear_text("view")
|
|
129
|
+
#
|
|
130
|
+
# will clear the text on _all_ visible views that respond to 'setText'
|
|
81
131
|
def clear_text(uiquery)
|
|
82
132
|
views_modified = map(uiquery, :setText, '')
|
|
83
|
-
|
|
133
|
+
msg = "query '#{uiquery}' returned no matching views that respond to 'setText'"
|
|
134
|
+
assert_map_results(views_modified, msg)
|
|
84
135
|
views_modified
|
|
85
136
|
end
|
|
86
137
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require 'edn'
|
|
2
2
|
require 'json'
|
|
3
|
+
# required for ruby 1.8
|
|
4
|
+
require 'enumerator'
|
|
3
5
|
|
|
4
6
|
module Calabash
|
|
5
7
|
module Cucumber
|
|
@@ -118,13 +120,18 @@ module Calabash
|
|
|
118
120
|
uia_handle_command(:screenshot, name)
|
|
119
121
|
end
|
|
120
122
|
|
|
121
|
-
def uia_type_string(string, opt_text_before=
|
|
123
|
+
def uia_type_string(string, opt_text_before='', escape=true)
|
|
124
|
+
if escape && string.index(/\\/)
|
|
125
|
+
indexes = string.enum_for(:scan,/\\/).map { Regexp.last_match.begin(0) }
|
|
126
|
+
indexes.reverse.each { |idx| string = string.insert(idx, '\\') }
|
|
127
|
+
end
|
|
122
128
|
res = uia_handle_command(:typeString, string, opt_text_before)
|
|
123
129
|
status = res['status']
|
|
124
130
|
if status.eql?('error')
|
|
125
131
|
value = res['value']
|
|
126
132
|
raise "could not type '#{string}' - '#{value}'"
|
|
127
133
|
end
|
|
134
|
+
status
|
|
128
135
|
end
|
|
129
136
|
|
|
130
137
|
def uia_enter
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: calabash-cucumber
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.166
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Karl Krukow
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-01-
|
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cucumber
|
|
@@ -156,14 +156,14 @@ dependencies:
|
|
|
156
156
|
requirements:
|
|
157
157
|
- - ~>
|
|
158
158
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: 0.1.
|
|
159
|
+
version: 0.1.2
|
|
160
160
|
type: :runtime
|
|
161
161
|
prerelease: false
|
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
163
163
|
requirements:
|
|
164
164
|
- - ~>
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: 0.1.
|
|
166
|
+
version: 0.1.2
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
|
168
168
|
name: awesome_print
|
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|