Skip to content

Commit

Permalink
Merge pull request #142 from appium/wip
Browse files Browse the repository at this point in the history
Update capabilities and appium.txt
  • Loading branch information
bootstraponline committed Apr 17, 2014
2 parents 62dc430 + fb61522 commit 8be5b7c
Show file tree
Hide file tree
Showing 94 changed files with 388 additions and 384 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions android_tests/appium.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[caps]
platformName = "android"
app = "./api.apk"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: utf-8

# rake android[android/helper]
describe 'android/helper' do
t 'tag_name_to_android' do
act = tag_name_to_android 'abslist'
Expand All @@ -16,8 +16,12 @@
end

t 'find_eles_attr' do
exp = ["API Demos", "Accessibility", "Animation", "App", "Content", "Graphics", "Media", "NFC", "OS", "Preference", "Text", "Views"]

# must wait for page to load
ignore { wait_true(10) { find_eles_attr(:text) == exp } }
act = find_eles_attr :text
exp = ['API Demos', 'Accessibility', 'Animation', 'App', 'Content', 'Graphics', 'Media', 'NFC', 'OS', 'Preference', 'Text', 'Views']

act.must_equal exp
end

Expand Down Expand Up @@ -54,7 +58,6 @@ def page_class_data
fast_duration.must_equal 0.0357
end


def id_key
'animation_2_instructions'
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# encoding: utf-8
# rake android[driver]
describe 'driver' do
def is_sauce
ENV['UPLOAD_FILE'] && ENV['SAUCE_USERNAME']
end

t 'load_appium_txt' do
# __FILE__ is '(eval)' so use env var set by the Rakefile
path = ENV['APPIUM_TXT']
puts "appium.txt path in test is: #{path}"
load_appium_txt file: path, verbose: true
apk_name = File.basename(ENV['APP_PATH'])
parsed = Appium.load_appium_txt file: ENV['APPIUM_TXT'], verbose: true
apk_name = File.basename parsed[:caps][:app]
assert_equal apk_name, 'api.apk'
end

Expand All @@ -21,45 +23,28 @@
end

t 'app_path attr' do
apk_name = File.basename app_path
apk_name = File.basename driver_attributes[:caps][:app]
apk_name.must_equal 'api.apk'
end

# Only used for Sauce Labs
t 'app_name attr' do
app_name.must_be_nil
end

t 'device attr' do
device.must_equal 'android'
end

t 'app_package attr' do
app_package.must_be_nil
end

t 'app_activity attr' do
app_activity.must_be_nil
end

t 'app_wait_activity attr' do
app_wait_activity.must_be_nil
end

t 'sauce_username attr' do
sauce_username.must_be_nil
end

t 'sauce_access_key attr' do
sauce_access_key.must_be_nil
end

t 'port attr' do
port.must_equal 4723
end

t 'debug attr' do
debug.must_equal true
t 'verify all attributes' do
2.times { set_wait 1 } # must set twice to validate last_waits
actual = driver_attributes
actual[:caps][:app] = File.basename actual[:caps][:app]
expected = { caps: { platformName: 'android',
app: 'api.apk' },
custom_url: false,
export_session: false,
default_wait: 1,
last_waits: [1, 1],
sauce_username: nil,
sauce_access_key: nil,
port: 4723,
device: 'android',
debug: true }

actual.must_equal expected
end
end

Expand All @@ -74,8 +59,13 @@
end

t 'absolute_app_path' do
def absolute_app_path path; $driver.class.absolute_app_path path; end
def validate_path path; absolute_app_path(path).must_equal path; end
def absolute_app_path path;
$driver.class.absolute_app_path path;
end

def validate_path path;
absolute_app_path(path).must_equal path;
end

validate_path 'sauce-storage:some_storage_suffix'
validate_path 'http://www.saucelabs.com'
Expand Down Expand Up @@ -107,7 +97,7 @@ def validate_path path; absolute_app_path(path).must_equal path; end
# invalid path test
invalid_path_errors = false
begin
absolute_app_path('../../does_not_exist.apk')
absolute_app_path('../../does_not_exist.apk')
rescue Exception
invalid_path_errors = true
ensure
Expand All @@ -118,34 +108,16 @@ def validate_path path; absolute_app_path(path).must_equal path; end

describe 'methods' do
t 'status' do
status.keys.sort.must_equal %w(sessionId status value)
appium_server_version['build'].keys.sort.must_equal %w(revision version)
end

t 'server_version' do
server_version.must_match /(\d+)\.(\d+).(\d+)/
end

def expected_android_capabilities
{ :compressXml => false,
:platform => 'Linux',
:platformName => 'android',
:fullReset => true,
:noReset => false,
:'device-type' => 'tablet',
:'device-orientation' => 'portrait',
:name => 'Ruby Console Android Appium',
:'app-package' => nil,
:'app-activity' => nil,
:'app-wait-activity' => nil,
app: 'api.apk' }
end

t 'capabilities' do
exp = expected_android_capabilities

act = capabilities
act[:app] = File.basename act[:app]
act.must_equal exp
server_version = appium_server_version['build']['version']
if is_sauce
server_version.must_match 'Sauce OnDemand'
else
server_version.must_match /(\d+)\.(\d+).(\d+)/
end
end

=begin
Expand Down Expand Up @@ -173,6 +145,7 @@ def expected_android_capabilities
set_wait # posts value to server, it's not stored locally
=end
t 'default_wait' do
set_wait 1
default_wait.must_equal 1
end

Expand Down
File renamed without changes.
12 changes: 4 additions & 8 deletions ruby_lib_android/lib/run.rb → android_tests/lib/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
a = OpenStruct.new x: 'ok'
raise 'x issue' unless a.x == 'ok'

load_appium_txt file: ENV['APPIUM_TXT'], verbose: true

dir = File.expand_path '..', __FILE__
device = ARGV[0].downcase.strip
devices = %w[ android selendroid ios ]
Expand All @@ -27,13 +25,11 @@
one_test = ARGV[1]
test_dir = "/#{device}/"

puts 'Start driver'
use_selendroid = device == 'selendroid'
puts "Use selendroid? #{use_selendroid}"

ENV['APP_PATH'] = ENV['SAUCE_PATH'] if ENV['SAUCE_USERNAME'] && ENV['SAUCE_ACCESS_KEY']
caps = Appium.load_appium_txt file: ENV['APPIUM_TXT'], verbose: true
caps = caps.merge({ appium_lib: { debug: true, wait: 1 } })
caps[:app] = ENV['SAUCE_PATH'] if ENV['SAUCE_USERNAME'] && ENV['SAUCE_ACCESS_KEY']

Appium::Driver.new(fast_clear: true, debug: true, wait: 1).start_driver
Appium::Driver.new(caps).start_driver

=begin
# Android doesn't like to be reset before booting up
Expand Down
4 changes: 2 additions & 2 deletions ruby_lib_android/readme.md → android_tests/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ api.apk is from [appium/android-apidemos](https://github.com/appium/android-apid
--

```java
Finished in 2 mins 12 secs
Finished in 2 mins 8 secs

103 runs, 129 assertions, 0 failures, 0 errors, 0 skips
94 runs, 120 assertions, 0 failures, 0 errors, 0 skips
```
File renamed without changes.
4 changes: 2 additions & 2 deletions appium_lib.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/appium/ruby_lib' # published as appium_lib
s.require_paths = [ 'lib' ]

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

s.add_development_dependency 'rake', '~> 10.0', '>= 10.0.4'
s.add_development_dependency 'rake', '~> 10.2', '>= 10.2.2'
s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7.3'

s.files = `git ls-files`.split "\n"
Expand Down
3 changes: 2 additions & 1 deletion ruby_lib_ios/Gemfile → ios_tests/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source 'https://rubygems.org'
gem 'test_runner', '>= 0.9.37'
gem 'rake', '~> 10.2.2'
gem 'rake', '~> 10.2.2'
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
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
3 changes: 3 additions & 0 deletions ios_tests/appium.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[caps]
platformName = "ios"
app = "./UICatalog.app"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8be5b7c

Please sign in to comment.