Last active
May 26, 2020 14:36
-
-
Save Alona-T/63d89a5c4f19a479629d7879cd6717f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'appium_lib' | |
username = 'User Name from Browserstack' | |
access_key = 'Access Key from Browserstack' | |
case ENV['SERVER'] | |
when 'LOCAL' | |
case ENV['PLATFORM'] | |
when 'ANDROID' | |
case ENV['DEVICE_NAME'] | |
when "Pixel" | |
caps = Appium.load_appium_txt\ | |
file: File.expand_path("../../support/caps/pixel.txt", __FILE__),\ #i do use caps in txt files for local tests | |
verbose: true | |
when "Nexus" | |
caps = Appium.load_appium_txt\ | |
file: File.expand_path("../../support/caps/nexus.txt", __FILE__),\ #i do use caps in txt files for local tests | |
verbose: true | |
when "Nexussmall" | |
caps = Appium.load_appium_txt\ | |
file: File.expand_path("../../support/caps/nexus_small.txt", __FILE__),\ #i do use caps in txt files for local tests | |
verbose: true | |
end | |
Appium::Driver.new(caps, true) | |
Appium.promote_appium_methods Object | |
when 'IOS' | |
case ENV['DEVICE_NAME'] | |
when "iPhoneXR" | |
caps = Appium.load_appium_txt\ | |
file: File.expand_path("../../support/caps/iPhoneXR.txt", __FILE__),\ #i do use caps in txt files for local tests | |
verbose: true | |
when "iPhone8Plus" | |
caps = Appium.load_appium_txt\ | |
file: File.expand_path("../../support/caps/iPhone8Plus.txt", __FILE__),\ #i do use caps in txt files for local tests | |
verbose: true | |
when "iPhone11" | |
caps = Appium.load_appium_txt\ | |
file: File.expand_path("../../support/caps/iPhone11.txt", __FILE__),\ #i do use caps in txt files for local tests | |
verbose: true | |
end | |
Appium::Driver.new(caps, true) | |
Appium.promote_appium_methods Object | |
end | |
when 'BROWSERSTACK' | |
case ENV['PLATFORM'] | |
when 'ANDROID' | |
case ENV['DEVICE_NAME'] | |
when "SamsungS10E" | |
caps = {} | |
caps['build'] = 'Ruby Appium Sample' | |
caps['name'] = 'single_test' | |
caps['device'] = 'Samsung Galaxy S10e' | |
caps['platformName'] = 'android' | |
caps['browserstack.debug'] = true | |
caps['app'] = 'bs://yourApp from API response' | |
caps['autoGrantPermissions'] = true | |
appium_driver = Appium::Driver.new({ | |
'caps' => caps, | |
'appium_lib' => { | |
:server_url => "http://#{username}:#{access_key}@hub-cloud.browserstack.com/wd/hub"}}, true) | |
when "GooglePixel" | |
caps = {} | |
caps['build'] = 'Ruby Appium Sample' | |
caps['name'] = 'single_test' | |
caps['device'] = 'Google Pixel 3' | |
caps['platformName'] = 'android' | |
caps['browserstack.debug'] = true | |
caps['app'] = 'bs://yourApp from API response' | |
caps['autoGrantPermissions'] = true #this is just to accept all permissions (location, push etc) | |
appium_driver = Appium::Driver.new({ | |
'caps' => caps, | |
'appium_lib' => { | |
:server_url => "http://#{username}:#{access_key}@hub-cloud.browserstack.com/wd/hub"}}, true) | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment