Skip to content

Commit 19a2cf8

Browse files
Update tests
1 parent 5e10809 commit 19a2cf8

File tree

25 files changed

+88
-108
lines changed

25 files changed

+88
-108
lines changed

Rakefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ require 'date'
55
require 'posix/spawn'
66

77
# Defines gem name.
8-
def repo_name;
8+
def repo_name
99
'appium_lib'
1010
end
1111

1212
# ruby_lib published as appium_lib
13-
def gh_name;
13+
def gh_name
1414
'ruby_lib'
1515
end
1616

1717
# the name as used on github.com
18-
def version_file;
18+
def version_file
1919
"lib/#{repo_name}/common/version.rb"
2020
end
2121

22-
def version_rgx;
22+
def version_rgx
2323
/\s*VERSION\s*=\s*'([^']+)'/m
2424
end
2525

@@ -144,8 +144,8 @@ task :uninstall do
144144
cmd = "gem uninstall -aIx #{repo_name}"
145145
# rescue on gem not installed error.
146146
begin
147-
; sh "#{cmd}";
148-
rescue;
147+
sh "#{cmd}"
148+
rescue
149149
end
150150
end
151151

android_tests/Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ task :default => :android
66
# Run sh and ignore exception
77
def run_sh cmd
88
begin
9-
; sh cmd;
10-
rescue;
9+
sh cmd
10+
rescue
1111
end
1212
end
1313

android_tests/api.apk

28 Bytes
Binary file not shown.

android_tests/lib/android/specs/android/element/alert.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe 'android/element/alert.rb' do
1+
describe 'android/element/alert' do
22
def open_alert
33
# trigger the alert
44
wait { button('OK Cancel dialog with a long message').click }

android_tests/lib/android/specs/android/element/button.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def fade_in
2929
t 'buttons' do
3030
exp = ['Zoom in', 'Modern zoom in', 'Thumbnail zoom']
3131
wait { buttons('zoom').map { |e| e.text }.must_equal exp }
32+
wait { buttons.length.must_equal 6 }
3233
end
3334

3435
t 'first_button' do
@@ -47,9 +48,5 @@ def fade_in
4748
wait { buttons_exact(fade_in).first.name.must_equal fade_in }
4849
end
4950

50-
t 'e_buttons' do
51-
wait { e_buttons.length.must_equal 6 }
52-
end
53-
5451
t { after_last }
5552
end

android_tests/lib/android/specs/android/element/text.rb

+15-18
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,32 @@ def must_raise_no_element &block
55
proc { block.call }.must_raise Selenium::WebDriver::Error::NoSuchElementError
66
end
77

8-
t 's_text' do
9-
wait { s_text(1).text.must_equal 'API Demos' }
10-
wait { s_text('mos').text.must_equal 'API Demos' }
8+
t 'text' do
9+
wait { text(1).text.must_equal 'API Demos' }
10+
wait { text('mos').text.must_equal 'API Demos' }
1111
end
1212

13-
t 's_texts' do
14-
wait { s_texts('i').length.must_equal 7 }
13+
t 'texts' do
14+
wait { texts('i').length.must_equal 6 }
15+
wait { texts.length.must_equal 12 }
1516
end
1617

17-
t 'first_s_text' do
18-
wait { first_s_text.text.must_equal 'API Demos' }
18+
t 'first_text' do
19+
wait { first_text.text.must_equal 'API Demos' }
1920
end
2021

21-
t 'last_s_text' do
22-
wait { last_s_text.text.must_equal 'Views' }
22+
t 'last_text' do
23+
wait { last_text.text.must_equal 'Views' }
2324
end
2425

25-
t 's_text_exact' do
26-
must_raise_no_element { s_text_exact 'mos' }
26+
t 'text_exact' do
27+
must_raise_no_element { text_exact 'mos' }
2728

2829
# should pass
29-
wait { s_text_exact('API Demos').text.must_equal 'API Demos' }
30+
wait { text_exact('API Demos').text.must_equal 'API Demos' }
3031
end
3132

32-
t 's_texts_exact' do
33-
wait { s_texts_exact('API Demos').length.must_equal 1 }
34-
end
35-
36-
t 'e_s_texts' do
37-
wait { e_s_texts.length.must_equal 14 }
33+
t 'texts_exact' do
34+
wait { texts_exact('API Demos').length.must_equal 1 }
3835
end
3936
end

android_tests/lib/android/specs/android/element/textfield.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def after_last
3232

3333
t 'textfields' do
3434
wait { textfields('right').first.text.must_equal right }
35+
wait { textfields.length.must_equal 2 }
3536
end
3637

3738
t 'first_textfield' do
@@ -52,9 +53,5 @@ def after_last
5253
wait { textfields_exact(left).first.text.must_equal left }
5354
end
5455

55-
t 'e_textfields' do
56-
wait { e_textfields.length.must_equal 2 }
57-
end
58-
5956
t { after_last }
6057
end

android_tests/lib/android/specs/android/helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rake android[android/helper]
22
describe 'android/helper' do
33
t 'tags' do
4-
wait { tags('android.widget.TextView').length.must_equal 14 }
4+
wait { tags('android.widget.TextView').length.must_equal 12 }
55
end
66

77
def page_class_data

android_tests/lib/android/specs/common/device.rb

+12-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
t 'reset' do
2222
reset
23-
wait { s_text(1).text.must_equal 'API Demos' }
23+
wait { text(1).text.must_equal 'API Demos' }
2424
end
2525

2626
t 'close & launch' do
@@ -42,13 +42,14 @@
4242

4343
t 'set_context' do
4444
wait do
45-
scroll_to "Views"
46-
last_s_text.click
47-
scroll_to 'WebView'
48-
last_s_text.click
45+
scroll_to('Views').click
46+
scroll_to('WebView').click
4947
set_context 'WEBVIEW'
5048
current_context.must_equal 'WEBVIEW_1'
5149
end
50+
51+
set_context 'NATIVE_APP'
52+
2.times { back; sleep 1 }
5253
end
5354

5455
t 'within_context' do
@@ -94,20 +95,20 @@ def must_return_element element
9495
end
9596
wait { find_element(:name, 'Custom View') }
9697
back
97-
wait { s_text_exact 'NFC' }
98+
wait { text_exact 'NFC' }
9899
end
99100

100101
t 'swipe' do
101102
wait { Appium::TouchAction.new.swipe(start_x: 0.75, start_y: 0.25, end_x: 0.75, end_y: 0.5, duration: 1.5).perform }
102-
wait { !exists { s_text_exact 'NFC' } }
103+
wait { !exists { text_exact 'NFC' } }
103104
back
104-
wait { s_text_exact 'NFC' }
105+
wait { text_exact 'NFC' }
105106
end
106107

107108
t 'pinch & zoom' do
108-
wait { s_text_exact 'NFC' }
109-
wait { s_text_exact('Graphics').click }
110-
wait { s_text('BitmapMesh').click }
109+
wait { text_exact 'NFC' }
110+
wait { text_exact('Graphics').click }
111+
wait { text('BitmapMesh').click }
111112
wait do
112113
zoom 200
113114
pinch 75

android_tests/lib/android/specs/common/helper.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545

4646
t 'back' do
4747
# start page
48-
wait { e_s_texts.length.must_equal 14 }
48+
wait { texts.length.must_equal 12 }
4949
# nav to new page.
5050
# ele 0 is the title and can't be clicked.
51-
wait { s_text(2).click }
52-
wait { e_s_texts.length.must_equal 8 }
51+
wait { text(2).click }
52+
wait { texts.length.must_equal 5 }
5353
# go back
5454
back
5555
# start page
@@ -65,15 +65,15 @@
6565
end
6666

6767
t 'xpaths' do
68-
wait { xpaths('//android.widget.TextView').length.must_equal 14 }
68+
wait { xpaths('//android.widget.TextView').length.must_equal 12 }
6969
end
7070

7171
t 'ele_index' do
7272
wait { ele_index('android.widget.TextView', 2).name.must_equal 'Accessibility' }
7373
end
7474

7575
t 'tags' do
76-
wait { tags('android.widget.TextView').length.must_equal 14 }
76+
wait { tags('android.widget.TextView').length.must_equal 12 }
7777
end
7878

7979
t 'find_ele_by_attr_include' do
@@ -86,7 +86,7 @@
8686
t 'find_eles_by_attr_include' do
8787
wait do
8888
ele_count = find_eles_by_attr_include('android.widget.TextView', :text, 'e').length
89-
ele_count.must_equal 9
89+
ele_count.must_equal 7
9090
end
9191
end
9292

android_tests/lib/android/specs/common/patch.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
# t 'value' do; end # Doesn't work on Android
1414

1515
t 'name' do
16-
wait { first_s_text.name.must_equal 'API Demos' }
16+
wait { first_text.name.must_equal 'API Demos' }
1717
end
1818

1919
# t 'tag_name' do; end # Doesn't work on Android
2020

2121
t 'location_rel' do
2222
wait do
23-
loc = first_s_text.location_rel
23+
loc = first_text.location_rel
2424
loc.x.class.must_equal String
2525
loc.y.class.must_equal String
2626
end
@@ -55,7 +55,7 @@
5555
t 'find many elements by resource id' do
5656
wait do
5757
value = find_elements(:id, 'android:id/text1').length
58-
value.must_equal 13
58+
value.must_equal 11
5959
end
6060
end
6161

android_tests/lib/android/specs/driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def validate_path path;
158158
# any elements
159159
t 'find_elements' do
160160
wait do
161-
find_elements(:class_name, 'android.widget.TextView').length.must_equal 14
161+
find_elements(:class_name, 'android.widget.TextView').length.must_equal 12
162162
end
163163
end
164164

ios_tests/Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ task :default => :ios
66
# Run sh and ignore exception
77
def run_sh cmd
88
begin
9-
; sh cmd;
10-
rescue;
9+
sh cmd
10+
rescue
1111
end
1212
end
1313

ios_tests/lib/ios/specs/common/helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def before_first
6565
# start page
6666
tag('UIANavigationBar').name.must_equal 'UICatalog'
6767
# nav to new page.
68-
wait_true { s_text('buttons').click; tag('UIANavigationBar').name == 'Buttons' }
68+
wait_true { text('buttons').click; tag('UIANavigationBar').name == 'Buttons' }
6969
tag('UIANavigationBar').name.must_equal 'Buttons'
7070
# go back
7171
back_click

ios_tests/lib/ios/specs/common/patch.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def before_first
1919
# todo: t 'value' do; end
2020

2121
t 'name' do
22-
first_s_text.name.must_equal 'UICatalog'
22+
first_text.name.must_equal 'UICatalog'
2323
end
2424

2525
# t 'tag_name' do; end # Doesn't work on Android
2626

2727
t 'location_rel' do
28-
loc = first_s_text.location_rel
28+
loc = first_text.location_rel
2929
loc.x.class.must_equal String
3030
loc.y.class.must_equal String
3131
end

ios_tests/lib/ios/specs/device/device.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ def before_first
6767
end
6868

6969
t 'swipe' do
70-
swipe start_x: 75, start_y: 500, end_x: 75, end_y: 0, duration: 0.8
70+
swipe start_x: 75, start_y: 500, end_x: 75, end_y: 0, duration: 800
7171
end
7272

7373
t 'pinch & zoom' do
74-
s_text('Images, Use of UIImageView').click
74+
text('Images, Use of UIImageView').click
7575
zoom 200
7676
pinch 75
7777
end

ios_tests/lib/ios/specs/driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def is_sauce
139139

140140
t 'restart' do
141141
restart
142-
s_text 'buttons'
142+
text 'buttons'
143143
end
144144

145145
t 'driver' do

ios_tests/lib/ios/specs/ios/element/alert.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
describe 'ios/element/alert' do
33
def nav_once
44
screen.must_equal catalog
5-
wait_true { s_text('alerts').click; tag('UIANavigationBar').name == 'Alerts' } # wait for true
5+
wait_true { text('alerts').click; tag('UIANavigationBar').name == 'Alerts' } # wait for true
66
tag('UIANavigationBar').name.must_equal 'Alerts'
77

88
# redefine method as no-op after it's invoked once
99
self.class.send :define_method, :nav_once, proc {}
1010
end
1111

1212
def after_last
13-
alert_accept if exists { s_text('UIActionSheet <title>') }
13+
alert_accept if exists { text('UIActionSheet <title>') }
1414
back_click
1515
screen.must_equal catalog
1616
sleep 1
@@ -23,9 +23,9 @@ def after_last
2323

2424
def open_alert
2525
wait_true do
26-
return true if exists { s_text('UIActionSheet <title>') }
27-
s_text('Show OK-Cancel').click
28-
s_text('UIActionSheet <title>').displayed?
26+
return true if exists { text('UIActionSheet <title>') }
27+
text('Show OK-Cancel').click
28+
text('UIActionSheet <title>').displayed?
2929
end
3030
end
3131

0 commit comments

Comments
 (0)