Skip to content

Commit 8be5b7c

Browse files
Merge pull request #142 from appium/wip
Update capabilities and appium.txt
2 parents 62dc430 + fb61522 commit 8be5b7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+388
-384
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

android_tests/appium.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[caps]
2+
platformName = "android"
3+
app = "./api.apk"

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# encoding: utf-8
2-
2+
# rake android[android/helper]
33
describe 'android/helper' do
44
t 'tag_name_to_android' do
55
act = tag_name_to_android 'abslist'
@@ -16,8 +16,12 @@
1616
end
1717

1818
t 'find_eles_attr' do
19+
exp = ["API Demos", "Accessibility", "Animation", "App", "Content", "Graphics", "Media", "NFC", "OS", "Preference", "Text", "Views"]
20+
21+
# must wait for page to load
22+
ignore { wait_true(10) { find_eles_attr(:text) == exp } }
1923
act = find_eles_attr :text
20-
exp = ['API Demos', 'Accessibility', 'Animation', 'App', 'Content', 'Graphics', 'Media', 'NFC', 'OS', 'Preference', 'Text', 'Views']
24+
2125
act.must_equal exp
2226
end
2327

@@ -54,7 +58,6 @@ def page_class_data
5458
fast_duration.must_equal 0.0357
5559
end
5660

57-
5861
def id_key
5962
'animation_2_instructions'
6063
end

ruby_lib_android/lib/android/specs/driver.rb android_tests/lib/android/specs/driver.rb

+40-67
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# encoding: utf-8
22
# rake android[driver]
33
describe 'driver' do
4+
def is_sauce
5+
ENV['UPLOAD_FILE'] && ENV['SAUCE_USERNAME']
6+
end
7+
48
t 'load_appium_txt' do
59
# __FILE__ is '(eval)' so use env var set by the Rakefile
6-
path = ENV['APPIUM_TXT']
7-
puts "appium.txt path in test is: #{path}"
8-
load_appium_txt file: path, verbose: true
9-
apk_name = File.basename(ENV['APP_PATH'])
10+
parsed = Appium.load_appium_txt file: ENV['APPIUM_TXT'], verbose: true
11+
apk_name = File.basename parsed[:caps][:app]
1012
assert_equal apk_name, 'api.apk'
1113
end
1214

@@ -21,45 +23,28 @@
2123
end
2224

2325
t 'app_path attr' do
24-
apk_name = File.basename app_path
26+
apk_name = File.basename driver_attributes[:caps][:app]
2527
apk_name.must_equal 'api.apk'
2628
end
2729

2830
# Only used for Sauce Labs
29-
t 'app_name attr' do
30-
app_name.must_be_nil
31-
end
32-
33-
t 'device attr' do
34-
device.must_equal 'android'
35-
end
36-
37-
t 'app_package attr' do
38-
app_package.must_be_nil
39-
end
40-
41-
t 'app_activity attr' do
42-
app_activity.must_be_nil
43-
end
44-
45-
t 'app_wait_activity attr' do
46-
app_wait_activity.must_be_nil
47-
end
48-
49-
t 'sauce_username attr' do
50-
sauce_username.must_be_nil
51-
end
52-
53-
t 'sauce_access_key attr' do
54-
sauce_access_key.must_be_nil
55-
end
56-
57-
t 'port attr' do
58-
port.must_equal 4723
59-
end
60-
61-
t 'debug attr' do
62-
debug.must_equal true
31+
t 'verify all attributes' do
32+
2.times { set_wait 1 } # must set twice to validate last_waits
33+
actual = driver_attributes
34+
actual[:caps][:app] = File.basename actual[:caps][:app]
35+
expected = { caps: { platformName: 'android',
36+
app: 'api.apk' },
37+
custom_url: false,
38+
export_session: false,
39+
default_wait: 1,
40+
last_waits: [1, 1],
41+
sauce_username: nil,
42+
sauce_access_key: nil,
43+
port: 4723,
44+
device: 'android',
45+
debug: true }
46+
47+
actual.must_equal expected
6348
end
6449
end
6550

@@ -74,8 +59,13 @@
7459
end
7560

7661
t 'absolute_app_path' do
77-
def absolute_app_path path; $driver.class.absolute_app_path path; end
78-
def validate_path path; absolute_app_path(path).must_equal path; end
62+
def absolute_app_path path;
63+
$driver.class.absolute_app_path path;
64+
end
65+
66+
def validate_path path;
67+
absolute_app_path(path).must_equal path;
68+
end
7969

8070
validate_path 'sauce-storage:some_storage_suffix'
8171
validate_path 'http://www.saucelabs.com'
@@ -107,7 +97,7 @@ def validate_path path; absolute_app_path(path).must_equal path; end
10797
# invalid path test
10898
invalid_path_errors = false
10999
begin
110-
absolute_app_path('../../does_not_exist.apk')
100+
absolute_app_path('../../does_not_exist.apk')
111101
rescue Exception
112102
invalid_path_errors = true
113103
ensure
@@ -118,34 +108,16 @@ def validate_path path; absolute_app_path(path).must_equal path; end
118108

119109
describe 'methods' do
120110
t 'status' do
121-
status.keys.sort.must_equal %w(sessionId status value)
111+
appium_server_version['build'].keys.sort.must_equal %w(revision version)
122112
end
123113

124114
t 'server_version' do
125-
server_version.must_match /(\d+)\.(\d+).(\d+)/
126-
end
127-
128-
def expected_android_capabilities
129-
{ :compressXml => false,
130-
:platform => 'Linux',
131-
:platformName => 'android',
132-
:fullReset => true,
133-
:noReset => false,
134-
:'device-type' => 'tablet',
135-
:'device-orientation' => 'portrait',
136-
:name => 'Ruby Console Android Appium',
137-
:'app-package' => nil,
138-
:'app-activity' => nil,
139-
:'app-wait-activity' => nil,
140-
app: 'api.apk' }
141-
end
142-
143-
t 'capabilities' do
144-
exp = expected_android_capabilities
145-
146-
act = capabilities
147-
act[:app] = File.basename act[:app]
148-
act.must_equal exp
115+
server_version = appium_server_version['build']['version']
116+
if is_sauce
117+
server_version.must_match 'Sauce OnDemand'
118+
else
119+
server_version.must_match /(\d+)\.(\d+).(\d+)/
120+
end
149121
end
150122

151123
=begin
@@ -173,6 +145,7 @@ def expected_android_capabilities
173145
set_wait # posts value to server, it's not stored locally
174146
=end
175147
t 'default_wait' do
148+
set_wait 1
176149
default_wait.must_equal 1
177150
end
178151

File renamed without changes.

ruby_lib_android/lib/run.rb android_tests/lib/run.rb

+4-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
a = OpenStruct.new x: 'ok'
1818
raise 'x issue' unless a.x == 'ok'
1919

20-
load_appium_txt file: ENV['APPIUM_TXT'], verbose: true
21-
2220
dir = File.expand_path '..', __FILE__
2321
device = ARGV[0].downcase.strip
2422
devices = %w[ android selendroid ios ]
@@ -27,13 +25,11 @@
2725
one_test = ARGV[1]
2826
test_dir = "/#{device}/"
2927

30-
puts 'Start driver'
31-
use_selendroid = device == 'selendroid'
32-
puts "Use selendroid? #{use_selendroid}"
33-
34-
ENV['APP_PATH'] = ENV['SAUCE_PATH'] if ENV['SAUCE_USERNAME'] && ENV['SAUCE_ACCESS_KEY']
28+
caps = Appium.load_appium_txt file: ENV['APPIUM_TXT'], verbose: true
29+
caps = caps.merge({ appium_lib: { debug: true, wait: 1 } })
30+
caps[:app] = ENV['SAUCE_PATH'] if ENV['SAUCE_USERNAME'] && ENV['SAUCE_ACCESS_KEY']
3531

36-
Appium::Driver.new(fast_clear: true, debug: true, wait: 1).start_driver
32+
Appium::Driver.new(caps).start_driver
3733

3834
=begin
3935
# Android doesn't like to be reset before booting up

ruby_lib_android/readme.md android_tests/readme.md

+2-2
File renamed without changes.

appium_lib.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ Gem::Specification.new do |s|
2424
s.homepage = 'https://github.com/appium/ruby_lib' # published as appium_lib
2525
s.require_paths = [ 'lib' ]
2626

27-
s.add_runtime_dependency 'selenium-webdriver', '~> 2.39', '>= 2.39.0'
27+
s.add_runtime_dependency 'selenium-webdriver', '~> 2.41', '>= 2.41.0'
2828
s.add_runtime_dependency 'awesome_print', '~> 1.2', '>= 1.2.0'
2929
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.1'
3030
s.add_runtime_dependency 'toml', '~> 0.0', '>= 0.0.4'
3131
s.add_runtime_dependency 'posix-spawn', '~> 0.3', '>= 0.3.8'
3232

33-
s.add_development_dependency 'rake', '~> 10.0', '>= 10.0.4'
33+
s.add_development_dependency 'rake', '~> 10.2', '>= 10.2.2'
3434
s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7.3'
3535

3636
s.files = `git ls-files`.split "\n"
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
source 'https://rubygems.org'
22
gem 'test_runner', '>= 0.9.37'
3-
gem 'rake', '~> 10.2.2'
3+
gem 'rake', '~> 10.2.2'
4+
gem 'selenium-webdriver', '>= 2.41.0'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

ios_tests/appium.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[caps]
2+
platformName = "ios"
3+
app = "./UICatalog.app"
File renamed without changes.

0 commit comments

Comments
 (0)