From 2ae45d2dddb7446a82b8ba349586a2305234432b Mon Sep 17 00:00:00 2001 From: UchihaMadaraaa Date: Wed, 28 May 2025 22:07:00 +0530 Subject: [PATCH] TTN-23587 minimal changes to get the tests running --- .DS_Store | Bin 6148 -> 6148 bytes .gitignore | 4 + android/examples/Gemfile | 11 +- android/examples/Gemfile.lock | 126 +++++++-------- .../run-first-test/features/support/env.rb | 83 ++++------ .../features/support/env.rb | 85 ++++------- ios/examples/Gemfile | 14 +- ios/examples/Gemfile.lock | 143 +++++++++--------- .../run-first-test/features/first.feature | 2 +- .../features/step_definitions/first_steps.rb | 68 ++++++--- .../run-first-test/features/support/env.rb | 83 ++++------ .../features/distinct.feature | 2 +- .../step_definitions/distinct_steps.rb | 68 ++++++--- .../features/support/env.rb | 85 ++++------- 14 files changed, 350 insertions(+), 424 deletions(-) diff --git a/.DS_Store b/.DS_Store index 4dac95d12d520a619dfe7f23225ee460e56eff0a..6c1a748e3b1971a46e1dd3ebb39637d1a56663eb 100644 GIT binary patch delta 70 zcmZoMXfc=|#>B)qF;Q%yo+2a9#(>?7j69QhSZXIrvQFA8&Gv?IVFB}Ib`E|HpsLM+ Y9N(EI^NTogFaQA~0|U$E2$40+0EEmCkpKVy delta 298 zcmZoMXfc=|#>B!kF;Q%yo+6{j#(>?7ix)66F^Wv)VX9?xoZQ7E#UY%_z`(%H;5c~= zlZ1bHe%}B5j3bT^A%;AL6ow*(e1=Shl-&Fjm!zEhB%lljZdC;thQZ1CxdlK~K#(xG znQ2D7KSOX%IC0y*Mz(LW7V}-k h&Fmcf9Kev+Jdyc3^JIPzM-D~?1}2b>%@HDNm;nWGNTL7$ diff --git a/.gitignore b/.gitignore index e3200e0..2206bcc 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ build-iPhoneSimulator/ /vendor/bundle /lib/bundler/man/ + # for a library or gem, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: # Gemfile.lock @@ -54,3 +55,6 @@ build-iPhoneSimulator/ # Used by RuboCop. Remote config files pulled in from inherit_from directive. # .rubocop-https?--* +.idea/ +.ds_store +.DS_Store diff --git a/android/examples/Gemfile b/android/examples/Gemfile index 229a8ef..ce46ec3 100644 --- a/android/examples/Gemfile +++ b/android/examples/Gemfile @@ -1,9 +1,10 @@ -source 'http://rubygems.org' +source 'https://rubygems.org' -gem 'cucumber' +gem 'cucumber', '~> 3.1.2' gem 'selenium-cucumber' -gem 'selenium-webdriver', '~> 3.142', '>= 3.142.5' -gem 'rspec' +gem 'selenium-webdriver', '< 4.0' +gem 'rspec', '~> 3.12' gem 'rake' gem 'parallel_tests' -gem 'appium_lib' \ No newline at end of file +gem 'appium_lib', '~> 11.0' +gem 'dotenv', '~> 2.8' \ No newline at end of file diff --git a/android/examples/Gemfile.lock b/android/examples/Gemfile.lock index cc0dd64..d597762 100644 --- a/android/examples/Gemfile.lock +++ b/android/examples/Gemfile.lock @@ -1,105 +1,95 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - appium_lib (12.0.1) - appium_lib_core (~> 5.0) + appium_lib (11.2.0) + appium_lib_core (~> 4.1) nokogiri (~> 1.8, >= 1.8.1) - tomlrb (>= 1.1, < 3.0) - appium_lib_core (5.3.0) + tomlrb (~> 1.1) + appium_lib_core (4.7.1) faye-websocket (~> 0.11.0) - selenium-webdriver (~> 4.2, < 4.5) - builder (3.2.4) - childprocess (4.1.0) + selenium-webdriver (~> 3.14, >= 3.14.1) + backports (3.25.1) + base64 (0.2.0) + builder (3.3.0) + childprocess (3.0.0) chunky_png (1.4.0) - cucumber (8.0.0) - builder (~> 3.2, >= 3.2.4) - cucumber-ci-environment (~> 9.0, >= 9.0.4) - cucumber-core (~> 11.0, >= 11.0.0) - cucumber-cucumber-expressions (~> 15.1, >= 15.1.1) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-html-formatter (~> 19.1, >= 19.1.0) - cucumber-messages (~> 18.0, >= 18.0.0) - diff-lcs (~> 1.5, >= 1.5.0) - mime-types (~> 3.4, >= 3.4.1) - multi_test (~> 1.1, >= 1.1.0) - sys-uname (~> 1.2, >= 1.2.2) - cucumber-ci-environment (9.1.0) - cucumber-core (11.0.0) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-tag-expressions (~> 4.1, >= 4.1.0) - cucumber-cucumber-expressions (15.2.0) - cucumber-gherkin (23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-html-formatter (19.2.0) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-messages (18.0.0) - cucumber-tag-expressions (4.1.0) + cucumber (3.1.2) + builder (>= 2.1.2) + cucumber-core (~> 3.2.0) + cucumber-expressions (~> 6.0.1) + cucumber-wire (~> 0.0.1) + diff-lcs (~> 1.3) + gherkin (~> 5.1.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (3.2.1) + backports (>= 3.8.0) + cucumber-tag_expressions (~> 1.1.0) + gherkin (~> 5.0) + cucumber-expressions (6.0.1) + cucumber-tag_expressions (1.1.1) + cucumber-wire (0.0.1) diff-lcs (1.5.0) + dotenv (2.8.1) eventmachine (1.2.7) - faye-websocket (0.11.1) + faye-websocket (0.11.4) eventmachine (>= 0.12.0) - websocket-driver (>= 0.5.1) - ffi (1.15.5) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) + websocket-driver (>= 0.5.1, < 0.8.0) + gherkin (5.1.0) + multi_json (1.15.0) multi_test (1.1.0) - nokogiri (1.13.8-arm64-darwin) + nokogiri (1.18.8-arm64-darwin) racc (~> 1.4) - nokogiri (1.13.8-x86_64-darwin) + nokogiri (1.18.8-x86_64-darwin) racc (~> 1.4) parallel (1.22.1) parallel_tests (3.12.0) parallel - racc (1.6.0) + racc (1.8.1) rake (13.0.6) - rexml (3.2.5) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + 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.11.0) - rspec-mocks (3.11.1) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.4) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.0) - rubyzip (2.3.2) + rspec-support (~> 3.13.0) + rspec-support (3.13.3) + rubyzip (2.4.1) selenium-cucumber (3.1.5) appium_lib (>= 8.0.2) chunky_png (>= 1.3.5) cucumber (>= 2.3.0) rspec (>= 3.4.0) selenium-webdriver (>= 2.53.0) - selenium-webdriver (4.4.0) - childprocess (>= 0.5, < 5.0) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - sys-uname (1.2.2) - ffi (~> 1.1) - tomlrb (2.0.3) - websocket (1.2.9) - websocket-driver (0.7.5) + 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 arm64-darwin-21 + arm64-darwin-24 x86_64-darwin-21 DEPENDENCIES - appium_lib - cucumber + appium_lib (~> 11.0) + cucumber (~> 3.1.2) + dotenv (~> 2.8) parallel_tests rake - rspec + rspec (~> 3.12) selenium-cucumber - selenium-webdriver + selenium-webdriver (< 4.0) BUNDLED WITH 2.3.21 diff --git a/android/examples/run-first-test/features/support/env.rb b/android/examples/run-first-test/features/support/env.rb index 43a55e5..f3e338c 100644 --- a/android/examples/run-first-test/features/support/env.rb +++ b/android/examples/run-first-test/features/support/env.rb @@ -1,7 +1,6 @@ require 'yaml' require 'rspec' require 'selenium-cucumber' - require 'appium_lib' TASK_ID = (ENV['TASK_ID'] || 0).to_i @@ -9,68 +8,38 @@ CONFIG = YAML.load(File.read(File.join(File.dirname(__FILE__), "../../config/#{CONFIG_NAME}.config.yml"))) -@caps = CONFIG['common_caps'].merge(CONFIG['browser_caps'][TASK_ID]) - - -#$bs_local = nil - - -puts @caps.inspect - -us= @caps["user"].inspect -ak= @caps["key"].inspect -is= @caps["isRealMobile"].inspect -pl= @caps["platform"].inspect -dn= @caps["deviceName"].inspect -pv= @caps["platformVersion"].inspect -ap= @caps["app"].inspect - - - -user= us.gsub("\"", "") -accessKey=ak.gsub("\"", "") -isRealMobile= is.gsub("\"", "") -platform= pl.gsub("\"", "") -deviceName= dn.gsub("\"", "") -platformVersion= pv.gsub("\"", "") -app= ap.gsub("\"", "") -puts isRealMobile - - -caps={ - - "LT:Options" => { - - "build" => "Cucumber Android Single", - "name" => "Cucumber Sample Test", - "platformName" => platform, - "isRealMobile" => isRealMobile, - "deviceName" => deviceName, - "platformVersion" => platformVersion, - "app" => app, - "w3c" => true - -}, - - +username = ENV["LT_USERNAME"] || "YOUR_LT_USERNAME" +accessToken = ENV["LT_ACCESS_KEY"] || "YOUR_LT_ACCESS_KEY" + +caps = { + "lt:options" => { + :deviceName => "Galaxy S21 5G", + :platformName => "Android", + :platformVersion => "11", + :build => "Ruby Cucumber - Android single", + :name => "Ruby Android Test", + :isRealMobile => true, + :queueTimeout => 300, + :app => "YOUR_ANDROID_APP_ID", + :w3c => true, + :autoGrantPermissions => true + }, + :platformName => "Android" } - appium_driver = Appium::Driver.new({ - 'caps' => caps, - 'appium_lib' => { - :server_url => "https://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub" - #server_url: "https://webhook.site/5958677a-4db9-4253-bb76-5b98e97e4880" - }}, true) - - + 'caps' => caps, + 'appium_lib' => { + :server_url => "https://#{username}:#{accessToken}@mobile-hub.lambdatest.com/wd/hub" + } +}, true) begin - #$appium_driver = Appium::Driver.new(desired_caps, true) $driver = appium_driver.start_driver - #example.run -ensure - #$driver.quit +rescue => e + puts "Error starting driver: #{e.message}" + puts "Capabilities used: #{caps.inspect}" + raise e end diff --git a/android/examples/run-parallel-tests/features/support/env.rb b/android/examples/run-parallel-tests/features/support/env.rb index 9408563..9b763b7 100644 --- a/android/examples/run-parallel-tests/features/support/env.rb +++ b/android/examples/run-parallel-tests/features/support/env.rb @@ -1,76 +1,45 @@ require 'yaml' require 'rspec' require 'selenium-cucumber' - require 'appium_lib' TASK_ID = (ENV['TASK_ID'] || 0).to_i -CONFIG_NAME = ENV['CONFIG_NAME'] || 'first' +CONFIG_NAME = ENV['CONFIG_NAME'] || 'parallel' CONFIG = YAML.load(File.read(File.join(File.dirname(__FILE__), "../../config/#{CONFIG_NAME}.config.yml"))) -@caps = CONFIG['common_caps'].merge(CONFIG['browser_caps'][TASK_ID]) - - -#$bs_local = nil - - -puts @caps.inspect - -us= @caps["user"].inspect -ak= @caps["key"].inspect -is= @caps["isRealMobile"].inspect -pl= @caps["platform"].inspect -dn= @caps["deviceName"].inspect -pv= @caps["platformVersion"].inspect -ap= @caps["app"].inspect - - - -user= us.gsub("\"", "") -accessKey=ak.gsub("\"", "") -isRealMobile= is.gsub("\"", "") -platform= pl.gsub("\"", "") -deviceName= dn.gsub("\"", "") -platformVersion= pv.gsub("\"", "") -app= ap.gsub("\"", "") -puts isRealMobile - - -caps={ - - "LT:Options" => { - - "build" => "Cucumber Parallel Android", - "name" => "Cucumber Sample Test", - "platformName" => platform, - "isRealMobile" => isRealMobile, - "deviceName" => deviceName, - "platformVersion" => platformVersion, - "app" => app, - "w3c" => true - -}, - - +username = ENV["LT_USERNAME"] || "YOUR_LT_USERNAME" +accessToken = ENV["LT_ACCESS_KEY"] || "YOUR_LT_ACCESS_KEY" + +caps = { + "lt:options" => { + :deviceName => "Galaxy S21 5G", + :platformName => "Android", + :platformVersion => "11", + :build => "Ruby Cucumber - Android Parallel", + :name => "Ruby Android Parallel Test #{TASK_ID}", + :isRealMobile => true, + :queueTimeout => 300, + :app => "YOUR_ANDROID_APP_ID", + :w3c => true, + :autoGrantPermissions => true + }, + :platformName => "Android" } - appium_driver = Appium::Driver.new({ - 'caps' => caps, - 'appium_lib' => { - :server_url => "https://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub" - #server_url: "https://webhook.site/5958677a-4db9-4253-bb76-5b98e97e4880" - }}, true) - - + 'caps' => caps, + 'appium_lib' => { + :server_url => "https://#{username}:#{accessToken}@mobile-hub.lambdatest.com/wd/hub" + } +}, true) begin - #$appium_driver = Appium::Driver.new(desired_caps, true) $driver = appium_driver.start_driver - #example.run -ensure - #$driver.quit +rescue => e + puts "Error starting driver: #{e.message}" + puts "Capabilities used: #{caps.inspect}" + raise e end diff --git a/ios/examples/Gemfile b/ios/examples/Gemfile index f17381b..9df4f36 100644 --- a/ios/examples/Gemfile +++ b/ios/examples/Gemfile @@ -1,10 +1,8 @@ source 'http://rubygems.org' -gem 'cucumber' -gem 'selenium-cucumber' -gem 'selenium-webdriver' -gem 'rspec' -gem 'rake' - -gem 'parallel_tests' -gem 'appium_lib' +gem 'cucumber', '~> 3.1.2' +gem 'rspec', '~> 3.11.0' +gem 'selenium-cucumber', '~> 3.1.5' +gem 'appium_lib', '~> 11.2.0' +gem 'parallel_tests', '~> 3.12.0' +gem 'rake', '~> 13.0' diff --git a/ios/examples/Gemfile.lock b/ios/examples/Gemfile.lock index b9082cf..0e3be6c 100644 --- a/ios/examples/Gemfile.lock +++ b/ios/examples/Gemfile.lock @@ -1,104 +1,109 @@ GEM remote: http://rubygems.org/ specs: - appium_lib (12.0.1) - appium_lib_core (~> 5.0) + appium_lib (11.2.0) + appium_lib_core (~> 4.1) nokogiri (~> 1.8, >= 1.8.1) - tomlrb (>= 1.1, < 3.0) - appium_lib_core (5.3.0) + tomlrb (~> 1.1) + appium_lib_core (4.7.1) faye-websocket (~> 0.11.0) - selenium-webdriver (~> 4.2, < 4.5) - browserstack-local (1.4.0) - builder (3.2.4) - childprocess (4.1.0) + selenium-webdriver (~> 3.14, >= 3.14.1) + backports (3.25.1) + base64 (0.2.0) + builder (3.3.0) + childprocess (3.0.0) chunky_png (1.4.0) - cucumber (8.0.0) - builder (~> 3.2, >= 3.2.4) - cucumber-ci-environment (~> 9.0, >= 9.0.4) - cucumber-core (~> 11.0, >= 11.0.0) - cucumber-cucumber-expressions (~> 15.1, >= 15.1.1) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-html-formatter (~> 19.1, >= 19.1.0) - cucumber-messages (~> 18.0, >= 18.0.0) - diff-lcs (~> 1.5, >= 1.5.0) - mime-types (~> 3.4, >= 3.4.1) - multi_test (~> 1.1, >= 1.1.0) - sys-uname (~> 1.2, >= 1.2.2) - cucumber-ci-environment (9.1.0) - cucumber-core (11.0.0) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-tag-expressions (~> 4.1, >= 4.1.0) - cucumber-cucumber-expressions (15.2.0) - cucumber-gherkin (23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-html-formatter (19.2.0) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-messages (18.0.0) - cucumber-tag-expressions (4.1.0) - diff-lcs (1.5.0) + cucumber (3.1.2) + builder (>= 2.1.2) + cucumber-core (~> 3.2.0) + cucumber-expressions (~> 6.0.1) + cucumber-wire (~> 0.0.1) + diff-lcs (~> 1.3) + gherkin (~> 5.1.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (3.2.1) + backports (>= 3.8.0) + cucumber-tag_expressions (~> 1.1.0) + gherkin (~> 5.0) + cucumber-expressions (6.0.1) + cucumber-tag_expressions (1.1.1) + cucumber-wire (0.0.1) + diff-lcs (1.6.2) eventmachine (1.2.7) - faye-websocket (0.11.1) + faye-websocket (0.11.4) eventmachine (>= 0.12.0) - websocket-driver (>= 0.5.1) - ffi (1.15.5) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) + websocket-driver (>= 0.5.1, < 0.8.0) + gherkin (5.1.0) + multi_json (1.15.0) multi_test (1.1.0) - nokogiri (1.13.8-arm64-darwin) + nokogiri (1.18.8-aarch64-linux-gnu) racc (~> 1.4) - parallel (1.22.1) - parallel_tests (3.12.0) + 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) + parallel (1.27.0) + parallel_tests (3.12.1) parallel - racc (1.6.0) - rake (13.0.6) - rexml (3.2.5) + racc (1.8.1) + rake (13.2.1) rspec (3.11.0) rspec-core (~> 3.11.0) rspec-expectations (~> 3.11.0) rspec-mocks (~> 3.11.0) rspec-core (3.11.0) rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec-expectations (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) + rspec-mocks (3.11.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-support (3.11.0) - rubyzip (2.3.2) + rspec-support (3.11.1) + rubyzip (2.4.1) selenium-cucumber (3.1.5) appium_lib (>= 8.0.2) chunky_png (>= 1.3.5) cucumber (>= 2.3.0) rspec (>= 3.4.0) selenium-webdriver (>= 2.53.0) - selenium-webdriver (4.4.0) - childprocess (>= 0.5, < 5.0) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - sys-uname (1.2.2) - ffi (~> 1.1) - tomlrb (2.0.3) - websocket (1.2.9) - websocket-driver (0.7.5) + 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 - arm64-darwin-21 + 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 - browserstack-local - cucumber - parallel_tests - rake - rspec - selenium-cucumber - selenium-webdriver + appium_lib (~> 11.2.0) + cucumber (~> 3.1.2) + parallel_tests (~> 3.12.0) + rake (~> 13.0) + rspec (~> 3.11.0) + selenium-cucumber (~> 3.1.5) BUNDLED WITH - 2.3.21 + 2.6.9 diff --git a/ios/examples/run-first-test/features/first.feature b/ios/examples/run-first-test/features/first.feature index 8b3d523..667aa24 100644 --- a/ios/examples/run-first-test/features/first.feature +++ b/ios/examples/run-first-test/features/first.feature @@ -1,4 +1,4 @@ -Feature: App automation in android +Feature: App automation in IOS Scenario: Search for a term diff --git a/ios/examples/run-first-test/features/step_definitions/first_steps.rb b/ios/examples/run-first-test/features/step_definitions/first_steps.rb index fc5bdd1..2cc1b09 100644 --- a/ios/examples/run-first-test/features/step_definitions/first_steps.rb +++ b/ios/examples/run-first-test/features/step_definitions/first_steps.rb @@ -1,34 +1,60 @@ When /^I click on buttons app$/ do + wait = Selenium::WebDriver::Wait.new(:timeout => 10) - $driver.find_element(:id, "color").click - #Click on Color Button - $driver.find_element(:id, "color").click - #Click on Geolocation Button - $driver.find_element(:id, "geoLocation").click - #wait of 5 seconds + # Click on Color Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='color']") } + element.click + + # Click on Geolocation Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='geoLocation']") } + element.click + + # Wait for 5 seconds sleep(5) - #Click on back Button + + # Click back Button $driver.back - #Click on text Button to enter value - $driver.find_element(:id, "Text").click - #Click on Notification Button - $driver.find_element(:id, "notification").click - #Click on toast Button - $driver.find_element(:id, "toast").click - #Click on speedtest Button - $driver.find_element(:id, "speedTest").click - #Wait for 10 seconds + + # Click on Text Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='Text']") } + element.click + + # Click on Notification Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='notification']") } + element.click + + # Click on Toast Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='toast']") } + element.click + + # Click on Speed Test Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='speedTest']") } + element.click + + # Wait for 10 seconds sleep(10) + + # Go back $driver.back - $driver.find_element(:id, "Browser").click + + # Click on Browser Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='Browser']") } + element.click + sleep(5) - $driver.find_element(:id, "url").click - $driver.find_element(:id, "url").send_keys "https://www.lambdatest.com/" - $driver.find_element(:id, "find").click + + # Enter URL + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeTextField[@name='url']") } + element.click + element.send_keys "https://www.lambdatest.com/" + + # Click Find Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='find']") } + element.click + sleep(5) $driver.back $driver.execute_script("lambda-status=passed") - end diff --git a/ios/examples/run-first-test/features/support/env.rb b/ios/examples/run-first-test/features/support/env.rb index 19c10b1..e156296 100644 --- a/ios/examples/run-first-test/features/support/env.rb +++ b/ios/examples/run-first-test/features/support/env.rb @@ -1,7 +1,6 @@ require 'yaml' require 'rspec' require 'selenium-cucumber' - require 'appium_lib' TASK_ID = (ENV['TASK_ID'] || 0).to_i @@ -9,68 +8,38 @@ CONFIG = YAML.load(File.read(File.join(File.dirname(__FILE__), "../../config/#{CONFIG_NAME}.config.yml"))) -@caps = CONFIG['common_caps'].merge(CONFIG['browser_caps'][TASK_ID]) - - -#$bs_local = nil - - -puts @caps.inspect - -us= @caps["user"].inspect -ak= @caps["key"].inspect -is= @caps["isRealMobile"].inspect -pl= @caps["platform"].inspect -dn= @caps["deviceName"].inspect -pv= @caps["platformVersion"].inspect -ap= @caps["app"].inspect - - - -user= us.gsub("\"", "") -accessKey=ak.gsub("\"", "") -isRealMobile= is.gsub("\"", "") -platform= pl.gsub("\"", "") -deviceName= dn.gsub("\"", "") -platformVersion= pv.gsub("\"", "") -app= ap.gsub("\"", "") -puts isRealMobile - - -caps={ - - "LT:Options" => { - - "build" => "Cucumber iOS Single", - "name" => "Cucumber Sample Test", - "platformName" => platform, - "isRealMobile" => isRealMobile, - "deviceName" => deviceName, - "platformVersion" => platformVersion, - "app" => app, - "w3c" => true - -}, - - +username = ENV["LT_USERNAME"] || "YOUR_LT_USERNAME" +accessToken = ENV["LT_ACCESS_KEY"] || "YOUR_LT_ACCESS_KEY" + +caps = { + "lt:options" => { + :deviceName => "iPhone 14", + :platformName => "iOS", + :platformVersion => "16", + :build => "Ruby Cucumber - iOS Single", + :name => "Ruby iOS Test", + :isRealMobile => true, + :queueTimeout => 300, + :app => "YOUR_IOS_APP_ID", + :w3c => true, + :autoGrantPermissions => true + }, + :platformName => "iOS" } - appium_driver = Appium::Driver.new({ - 'caps' => caps, - 'appium_lib' => { - :server_url => "https://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub" - #server_url: "https://webhook.site/5958677a-4db9-4253-bb76-5b98e97e4880" - }}, true) - - + 'caps' => caps, + 'appium_lib' => { + :server_url => "https://#{username}:#{accessToken}@mobile-hub.lambdatest.com/wd/hub" + } +}, true) begin - #$appium_driver = Appium::Driver.new(desired_caps, true) $driver = appium_driver.start_driver - #example.run -ensure - #$driver.quit +rescue => e + puts "Error starting driver: #{e.message}" + puts "Capabilities used: #{caps.inspect}" + raise e end diff --git a/ios/examples/run-parallel-tests/features/distinct.feature b/ios/examples/run-parallel-tests/features/distinct.feature index 8b3d523..667aa24 100644 --- a/ios/examples/run-parallel-tests/features/distinct.feature +++ b/ios/examples/run-parallel-tests/features/distinct.feature @@ -1,4 +1,4 @@ -Feature: App automation in android +Feature: App automation in IOS Scenario: Search for a term diff --git a/ios/examples/run-parallel-tests/features/step_definitions/distinct_steps.rb b/ios/examples/run-parallel-tests/features/step_definitions/distinct_steps.rb index fc5bdd1..2cc1b09 100644 --- a/ios/examples/run-parallel-tests/features/step_definitions/distinct_steps.rb +++ b/ios/examples/run-parallel-tests/features/step_definitions/distinct_steps.rb @@ -1,34 +1,60 @@ When /^I click on buttons app$/ do + wait = Selenium::WebDriver::Wait.new(:timeout => 10) - $driver.find_element(:id, "color").click - #Click on Color Button - $driver.find_element(:id, "color").click - #Click on Geolocation Button - $driver.find_element(:id, "geoLocation").click - #wait of 5 seconds + # Click on Color Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='color']") } + element.click + + # Click on Geolocation Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='geoLocation']") } + element.click + + # Wait for 5 seconds sleep(5) - #Click on back Button + + # Click back Button $driver.back - #Click on text Button to enter value - $driver.find_element(:id, "Text").click - #Click on Notification Button - $driver.find_element(:id, "notification").click - #Click on toast Button - $driver.find_element(:id, "toast").click - #Click on speedtest Button - $driver.find_element(:id, "speedTest").click - #Wait for 10 seconds + + # Click on Text Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='Text']") } + element.click + + # Click on Notification Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='notification']") } + element.click + + # Click on Toast Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='toast']") } + element.click + + # Click on Speed Test Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='speedTest']") } + element.click + + # Wait for 10 seconds sleep(10) + + # Go back $driver.back - $driver.find_element(:id, "Browser").click + + # Click on Browser Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='Browser']") } + element.click + sleep(5) - $driver.find_element(:id, "url").click - $driver.find_element(:id, "url").send_keys "https://www.lambdatest.com/" - $driver.find_element(:id, "find").click + + # Enter URL + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeTextField[@name='url']") } + element.click + element.send_keys "https://www.lambdatest.com/" + + # Click Find Button + element = wait.until { $driver.find_element(:xpath, "//XCUIElementTypeButton[@name='find']") } + element.click + sleep(5) $driver.back $driver.execute_script("lambda-status=passed") - end diff --git a/ios/examples/run-parallel-tests/features/support/env.rb b/ios/examples/run-parallel-tests/features/support/env.rb index 86f1113..7e013e8 100644 --- a/ios/examples/run-parallel-tests/features/support/env.rb +++ b/ios/examples/run-parallel-tests/features/support/env.rb @@ -1,76 +1,45 @@ require 'yaml' require 'rspec' require 'selenium-cucumber' - require 'appium_lib' TASK_ID = (ENV['TASK_ID'] || 0).to_i -CONFIG_NAME = ENV['CONFIG_NAME'] || 'first' +CONFIG_NAME = ENV['CONFIG_NAME'] || 'parallel' CONFIG = YAML.load(File.read(File.join(File.dirname(__FILE__), "../../config/#{CONFIG_NAME}.config.yml"))) -@caps = CONFIG['common_caps'].merge(CONFIG['browser_caps'][TASK_ID]) - - -#$bs_local = nil - - -puts @caps.inspect - -us= @caps["user"].inspect -ak= @caps["key"].inspect -is= @caps["isRealMobile"].inspect -pl= @caps["platform"].inspect -dn= @caps["deviceName"].inspect -pv= @caps["platformVersion"].inspect -ap= @caps["app"].inspect - - - -user= us.gsub("\"", "") -accessKey=ak.gsub("\"", "") -isRealMobile= is.gsub("\"", "") -platform= pl.gsub("\"", "") -deviceName= dn.gsub("\"", "") -platformVersion= pv.gsub("\"", "") -app= ap.gsub("\"", "") -puts isRealMobile - - -caps={ - - "LT:Options" => { - - "build" => "Cucumber Parallel iOS", - "name" => "Cucumber Sample Test", - "platformName" => platform, - "isRealMobile" => isRealMobile, - "deviceName" => deviceName, - "platformVersion" => platformVersion, - "app" => app, - "w3c" => true - -}, - - +username = ENV["LT_USERNAME"] || "YOUR_LT_USERNAME" +accessToken = ENV["LT_ACCESS_KEY"] || "YOUR_LT_ACCESS_KEY" + +caps = { + "lt:options" => { + :deviceName => "iPhone 14", + :platformName => "iOS", + :platformVersion => "16", + :build => "Ruby Cucumber - iOS Parallel", + :name => "Ruby iOS Parallel Test #{TASK_ID}", + :isRealMobile => true, + :queueTimeout => 300, + :app => "YOUR_IOS_APP_ID", + :w3c => true, + :autoGrantPermissions => true + }, + :platformName => "iOS" } - appium_driver = Appium::Driver.new({ - 'caps' => caps, - 'appium_lib' => { - :server_url => "https://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub" - - }}, true) - - + 'caps' => caps, + 'appium_lib' => { + :server_url => "https://#{username}:#{accessToken}@mobile-hub.lambdatest.com/wd/hub" + } +}, true) begin - #$appium_driver = Appium::Driver.new(desired_caps, true) $driver = appium_driver.start_driver - #example.run -ensure - #$driver.quit +rescue => e + puts "Error starting driver: #{e.message}" + puts "Capabilities used: #{caps.inspect}" + raise e end