diff --git a/.gitignore b/.gitignore index a1c2a23..eec1f90 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +.idea/ diff --git a/ExecutionSteps_Readme.md b/ExecutionSteps_Readme.md new file mode 100644 index 0000000..94ed2b8 --- /dev/null +++ b/ExecutionSteps_Readme.md @@ -0,0 +1,46 @@ +# LambdaTest Appium Ruby Automation - Execution Steps + +## Prerequisites +- Ruby >= 2.7 +- Bundler (`gem install bundler`) +- LambdaTest credentials (username and access key) + +## 1. Install Dependencies + +### For Native (Appium) Android & iOS Tests +``` +bundle install +``` + +### For Web (Selenium) Android & iOS Tests +``` +BUNDLE_GEMFILE=Gemfile.web bundle install +``` + +## 2. Run Tests + +### Native Android +``` +LT_USERNAME= LT_ACCESS_KEY= BUNDLE_GEMFILE=Gemfile bundle exec ruby android/android-sample.rb +``` + +### Native iOS +``` +LT_USERNAME= LT_ACCESS_KEY= BUNDLE_GEMFILE=Gemfile bundle exec ruby ios/ios-sample.rb +``` + +### Web Android +``` +LT_USERNAME= LT_ACCESS_KEY= BUNDLE_GEMFILE=Gemfile.web bundle exec ruby android/android-web-sample.rb +``` + +### Web iOS +``` +LT_USERNAME= LT_ACCESS_KEY= BUNDLE_GEMFILE=Gemfile.web bundle exec ruby ios/ios-web-sample.rb +``` + +## Notes +- Use the correct Gemfile for each test type. +- If you see network or timeout errors, retry the command. +- Only two Gemfiles are needed: `Gemfile` (native) and `Gemfile.web` (web). +- No extra files or changes are required beyond this setup. \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e224a0c --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gem 'appium_lib', '~> 11.0' +gem 'rspec', '~> 3.12' +gem 'selenium-webdriver', '< 4.0' +gem 'dotenv', '~> 2.8' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e0facd5 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,76 @@ +GEM + remote: https://rubygems.org/ + specs: + appium_lib (11.2.0) + appium_lib_core (~> 4.1) + nokogiri (~> 1.8, >= 1.8.1) + tomlrb (~> 1.1) + appium_lib_core (4.7.1) + faye-websocket (~> 0.11.0) + selenium-webdriver (~> 3.14, >= 3.14.1) + base64 (0.2.0) + childprocess (3.0.0) + diff-lcs (1.6.2) + dotenv (2.8.1) + eventmachine (1.2.7) + faye-websocket (0.11.4) + eventmachine (>= 0.12.0) + websocket-driver (>= 0.5.1, < 0.8.0) + nokogiri (1.18.8-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.8-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-musl) + racc (~> 1.4) + racc (1.8.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.3) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.3) + rubyzip (2.4.1) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + tomlrb (1.3.0) + websocket-driver (0.7.7) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + appium_lib (~> 11.0) + dotenv (~> 2.8) + rspec (~> 3.12) + selenium-webdriver (< 4.0) + +BUNDLED WITH + 2.6.9 diff --git a/Gemfile.web b/Gemfile.web new file mode 100644 index 0000000..24d782d --- /dev/null +++ b/Gemfile.web @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gem 'selenium-webdriver', '~> 4.8.0' +gem 'rspec', '~> 3.12' +gem 'dotenv', '~> 2.8' +gem 'base64' \ No newline at end of file diff --git a/Gemfile.web.lock b/Gemfile.web.lock new file mode 100644 index 0000000..97999db --- /dev/null +++ b/Gemfile.web.lock @@ -0,0 +1,39 @@ +GEM + remote: https://rubygems.org/ + specs: + base64 (0.2.0) + diff-lcs (1.6.2) + dotenv (2.8.1) + rexml (3.4.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.3) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.3) + rubyzip (2.4.1) + selenium-webdriver (4.8.6) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + websocket (1.2.11) + +PLATFORMS + arm64-darwin-24 + ruby + +DEPENDENCIES + base64 + dotenv (~> 2.8) + rspec (~> 3.12) + selenium-webdriver (~> 4.8.0) + +BUNDLED WITH + 2.6.9 diff --git a/android/android-sample.rb b/android/android-sample.rb index a9d787a..500ee0b 100644 --- a/android/android-sample.rb +++ b/android/android-sample.rb @@ -14,7 +14,8 @@ :isRealMobile => true, :queueTimeout => 300, :app => "lt://proverbial-android", #Enter the App URL here - :w3c => true + :w3c => true, + :autoGrantPermissions => true }, :platformName => "Android" } diff --git a/android/android-web-sample.rb b/android/android-web-sample.rb index 4967bc7..0ec4ca0 100644 --- a/android/android-web-sample.rb +++ b/android/android-web-sample.rb @@ -1,5 +1,4 @@ require 'rubygems' -require 'appium_lib' require 'selenium-webdriver' username= ENV["LT_USERNAME"] || "LT_Username" #Enter your username here @@ -19,11 +18,13 @@ :platformName => "Android" } +capabilities = Selenium::WebDriver::Remote::Capabilities.new(caps) + driver = Selenium::WebDriver.for :remote, - :url => "https://"+username+":"+accessToken+"@mobile-hub.lambdatest.com/wd/hub", - :desired_capabilities => caps + url: "https://"+username+":"+accessToken+"@mobile-hub.lambdatest.com/wd/hub", + capabilities: capabilities - wait = Selenium::WebDriver::Wait.new(:timeout => 30) + wait = Selenium::WebDriver::Wait.new(timeout: 30) driver.navigate.to("https://mfml.in/api/getInfo") el1 = driver.find_element(:id => "resolution") el1.click diff --git a/ios/ios-web-sample.rb b/ios/ios-web-sample.rb index 4de98d9..95a79a5 100644 --- a/ios/ios-web-sample.rb +++ b/ios/ios-web-sample.rb @@ -1,5 +1,4 @@ require 'rubygems' -require 'appium_lib' require 'selenium-webdriver' username= ENV["LT_USERNAME"] || "LT_Username" #Enter your username here @@ -19,11 +18,13 @@ :platformName => "ios" } +capabilities = Selenium::WebDriver::Remote::Capabilities.new(caps) + driver = Selenium::WebDriver.for :remote, - :url => "https://"+username+":"+accessToken+"@mobile-hub.lambdatest.com/wd/hub", - :desired_capabilities => caps + url: "https://"+username+":"+accessToken+"@mobile-hub.lambdatest.com/wd/hub", + capabilities: capabilities - wait = Selenium::WebDriver::Wait.new(:timeout => 30) + wait = Selenium::WebDriver::Wait.new(timeout: 30) driver.navigate.to("https://mfml.in/api/getInfo") el1 = driver.find_element(:id => "resolution") el1.click