diff --git a/Gemfile b/Gemfile index 6d4947a..3a562e1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'http://rubygems.org' -gem 'appium_lib', ">=10.5.0" +gem 'appium_lib', ">=12.0.1" gem 'browserstack-local', ">=1.3.0" \ No newline at end of file diff --git a/README.md b/README.md index 400f7ef..5b7726a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ This repository demonstrates how to run Appium Ruby tests on BrowserStack App Automate. +## Based on + +These code samples are currently based on: + +- **appium_lib:** `12.0.1` +- **Protocol:** `W3C` ## Setup ### Requirements @@ -94,7 +100,7 @@ Open `browserstack_sample_local.rb` file in `android` or `ios` directory : - Set the device and OS version -- Ensure that `browserstack.local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Ruby binding for BrowserStack Local. +- Ensure that `local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Ruby binding for BrowserStack Local. - If you have uploaded your own app update the test case diff --git a/android/browserstack_sample.rb b/android/browserstack_sample.rb index f0aac8f..9036b0d 100644 --- a/android/browserstack_sample.rb +++ b/android/browserstack_sample.rb @@ -2,32 +2,35 @@ require 'appium_lib' require 'selenium-webdriver' -caps = {} -# Set your access credentials -caps['browserstack.user'] = 'YOUR_USERNAME' -caps['browserstack.key'] = 'YOUR_ACCESS_KEY' - -# Set URL of the application under test -caps['app'] = 'bs://' - -# Specify device and os_version for testing -caps['device'] = 'Google Pixel 3' -caps['os_version'] = '9.0' - -# Set other BrowserStack capabilities -caps['project'] = 'First Ruby project' -caps['build'] = 'browserstack-build-1' -caps['name'] = 'single_test' - -#Set the platform name -caps['platformName'] = 'android' +capabilities = { + # Specify device and os_version for testing + "platformName" => "android", + "platformVersion" => "9.0", + "deviceName" => "Google Pixel 3", + + # Set URL of the application under test + "app" => "bs://", + + # Set other BrowserStack capabilities + 'bstack:options' => { + "projectName" => "First Ruby project", + "buildName" => "browserstack-build-1", + "sessionName" => "BStack single_test", + "debug" => "true", + "networkLogs" => "true", + + # Set your access credentials + "userName": "BROWSERSTACK_USERNAME", + "accessKey": "BROWSERSTACK_ACCESS_KEY" + }, +} # Initialize the remote Webdriver using BrowserStack remote URL # and desired capabilities defined above appium_driver = Appium::Driver.new({ - 'caps' => caps, + 'caps' => capabilities, 'appium_lib' => { - :server_url => "http://hub-cloud.browserstack.com/wd/hub" + :server_url => "http://hub.browserstack.com/wd/hub" }}, true) driver = appium_driver.start_driver diff --git a/android/browserstack_sample_local.rb b/android/browserstack_sample_local.rb index 861aae5..1587bae 100644 --- a/android/browserstack_sample_local.rb +++ b/android/browserstack_sample_local.rb @@ -3,30 +3,32 @@ require 'selenium-webdriver' require 'browserstack/local' -username = 'YOUR_USERNAME' -access_key = 'YOUR_ACCESS_KEY' - -caps = {} # Set your access credentials -caps['browserstack.user'] = username -caps['browserstack.key'] = access_key +user_name = "BROWSERSTACK_USERNAME" +access_key = "BROWSERSTACK_ACCESS_KEY" -# Set URL of the application under test -caps['app'] = 'bs://' +capabilities = { + # Specify device and os_version for testing + "platformName" => "android", + "platformVersion" => "9.0", + "deviceName" => "Google Pixel 3", -# Specify device and os_version for testing -caps['device'] = 'Google Pixel 3' -caps['os_version'] = '9.0' + # Set URL of the application under test + "app" => "bs://", -# Set browserstack.local capability as true -caps['browserstack.local'] = true + # Set other BrowserStack capabilities + 'bstack:options' => { + "projectName" => "First Ruby project", + "buildName" => "browserstack-build-1", + "sessionName" => "BStack local_test", + "debug" => "true", + "local" => "true", + "networkLogs" => "true", -# Set other BrowserStack capabilities -caps['project'] = 'First Ruby project' -caps['build'] = 'browserstack-build-1' -caps['name'] = 'local_test' -caps['platformName'] = 'android' -caps['browserstack.debug'] = true + "userName": user_name, + "accessKey": access_key + }, +} # Start browserstack local bs_local = BrowserStack::Local.new @@ -36,9 +38,9 @@ # Initialize the remote Webdriver using BrowserStack remote URL # and desired capabilities defined above appium_driver = Appium::Driver.new({ - 'caps' => caps, + 'caps' => capabilities, 'appium_lib' => { - :server_url => "http://hub-cloud.browserstack.com/wd/hub" + :server_url => "http://hub.browserstack.com/wd/hub" }}, true) driver = appium_driver.start_driver diff --git a/ios/browserstack_sample.rb b/ios/browserstack_sample.rb index 152d65d..6f5f248 100644 --- a/ios/browserstack_sample.rb +++ b/ios/browserstack_sample.rb @@ -2,32 +2,35 @@ require 'appium_lib' require 'selenium-webdriver' -caps = {} -# Set your access credentials -caps['browserstack.user'] = 'YOUR_USERNAME' -caps['browserstack.key'] = 'YOUR_ACCESS_KEY' - -# Set URL of the application under test -caps['app'] = 'bs://' - -# Specify device and os_version for testing -caps['device'] = "iPhone 11 Pro" -caps['os_version'] = "13" - -# Set other BrowserStack capabilities -caps['project'] = 'First Ruby project' -caps['build'] = 'browserstack-build-1' -caps['name'] = 'single_test' - -#Set the platform name -caps['platformName'] = 'iOS' +capabilities = { + # Specify device and os_version for testing + "platformName" => "iOS", + "platformVersion" => "13", + "deviceName" => "iPhone 11 Pro", + + # Set URL of the application under test + "app" => "bs://", + + # Set other BrowserStack capabilities + 'bstack:options' => { + "projectName" => "First Ruby project", + "buildName" => "browserstack-build-1", + "sessionName" => "BStack single_test", + "debug" => "true", + "networkLogs" => "true", + + # Set your access credentials + "userName": "BROWSERSTACK_USERNAME", + "accessKey": "BROWSERSTACK_ACCESS_KEY" + }, +} # Initialize the remote Webdriver using BrowserStack remote URL # and desired capabilities defined above appium_driver = Appium::Driver.new({ - 'caps' => caps, + 'caps' => capabilities, 'appium_lib' => { - :server_url => "http://hub-cloud.browserstack.com/wd/hub" + :server_url => "http://hub.browserstack.com/wd/hub" }}, true) driver = appium_driver.start_driver diff --git a/ios/browserstack_sample_local.rb b/ios/browserstack_sample_local.rb index 26c8fb1..2c8a280 100644 --- a/ios/browserstack_sample_local.rb +++ b/ios/browserstack_sample_local.rb @@ -3,31 +3,32 @@ require 'selenium-webdriver' require 'browserstack/local' - -username = 'YOUR_USERNAME' -access_key = 'YOUR_ACCESS_KEY' - -caps = {} # Set your access credentials -caps['browserstack.user'] = username -caps['browserstack.key'] = access_key +user_name = "BROWSERSTACK_USERNAME" +access_key = "BROWSERSTACK_ACCESS_KEY" -# Set URL of the application under test -caps['app'] = 'bs://' +capabilities = { + # Specify device and os_version for testing + "platformName" => "iOS", + "platformVersion" => "12", + "deviceName" => "iPhone XS", -# Specify device and os_version for testing -caps['device'] = "iPhone 11 Pro" -caps['os_version'] = "13" + # Set URL of the application under test + "app" => "bs://", -# Set browserstack.local capability as true -caps['browserstack.local'] = true + # Set other BrowserStack capabilities + 'bstack:options' => { + "projectName" => "First Ruby project", + "buildName" => "browserstack-build-1", + "sessionName" => "BStack local_test", + "debug" => "true", + "local" => "true", + "networkLogs" => "true", -# Set other BrowserStack capabilities -caps['project'] = 'First Ruby project' -caps['build'] = 'browserstack-build-1' -caps['name'] = 'local_test' -caps['platformName'] = 'iOS' -caps['browserstack.debug'] = true + "userName": user_name, + "accessKey": access_key + }, +} # Start browserstack local bs_local = BrowserStack::Local.new @@ -37,9 +38,9 @@ # Initialize the remote Webdriver using BrowserStack remote URL # and desired capabilities defined above appium_driver = Appium::Driver.new({ - 'caps' => caps, + 'caps' => capabilities, 'appium_lib' => { - :server_url => "http://hub-cloud.browserstack.com/wd/hub" + :server_url => "http://hub.browserstack.com/wd/hub" }}, true) driver = appium_driver.start_driver