"Achieve Flawless iOS Automation: Setting Up Cucumber and Appium on Sauce Labs"
Welcome to the future of iOS testing, where automation meets convenience. In today's fast-paced development landscape, testing iOS apps manually isn’t just time-consuming—it’s a bottleneck. Imagine having the power to run your iOS tests seamlessly on Sauce Labs using Cucumber and Appium, while maintaining reliability and scalability. Let’s dive deep into the essential steps to achieve this!
Why Sauce Labs, Cucumber, and Appium?
Before jumping in, here's why this trio is a killer combination:
- Cucumber helps bring clarity to test cases by expressing them in simple English.
- Appium enables cross-platform mobile automation, and it supports iOS seamlessly.
- Sauce Labs provides scalability for running your automation scripts on multiple device platforms in the cloud.
Together, they create an environment that’s robust, scalable, and easy to manage for iOS app automation.
Step-by-Step Guide to Setting Up iOS Automation with Cucumber and Appium on Sauce Labs
Step 1: Prerequisites
-
Install Ruby with Bundler:
Cucumber requires the Ruby environment. Install Ruby (v2.7+ recommended), and include Bundler as it manages dependencies seamlessly within your project.
brew install ruby
gem install bundler
-
Install Node.js and NPM:
Appium requires Node.js (v16+) and NPM for setup.
brew install node
npm install -g appium
-
Set Up Appium:
Install the desktop Appium server to run tests locally before pushing them to Sauce Labs:
npm install -g appium-doctor
appium-doctor --ios
-
Install Xcode:
iOS automation requires Xcode and the necessary tools for building or simulating applications. Make sure you have the latest Xcode version installed.
Step 2: Install Dependencies for Your Cucumber Framework
-
Initialize your project folder:
mkdir ios-automation && cd ios-automation
bundle init
-
Add these dependencies to your Gemfile:
gem 'cucumber'
gem 'appium_lib'
gem 'selenium-webdriver'
Then, install them:
bundle install
-
To integrate Sauce Labs, you’ll want to install the rest-client gem to push test assets and get logs from the Sauce Labs cloud:
gem install rest-client
Step 3: Configure Appium with Sauce Labs
Create your caps.json file for Appium capabilities to run your tests on iOS devices through Sauce Labs. It should look something like this:
{
"platformName": "iOS",
"deviceName": "iPhone 14 Pro",
"platformVersion": "17.0",
"browserName": "",
"app": "sauce-storage:<YourAppName>.ipa",
"sauce:options": {
"username": "YOUR_SAUCE_USERNAME",
"accessKey": "YOUR_SAUCE_ACCESS_KEY",
"build": "BuildName",
"name": "TestName"
}
}
Replace <YourAppName> with your actual app name uploaded to Sauce Labs. Use the Sauce Labs dashboard to upload .ipa packages.
Step 4: Write Gherkin Test Scenarios
Gherkin simplifies writing test cases. Create a .feature file such as login.feature:
Feature: Login Functionality
As a user
I want to log in successfully
To access my account
Scenario: Successful login
Given I open the app
When I enter valid credentials
Then I should see the dashboard
Step 5: Implement the Step Definition File
Create a step definition file (step_definitions/login_steps.rb) and reference the Appium driver:
require 'appium_lib'
caps = Appium.load_appium_txt file: File.expand_path('./caps.json', __dir__)
Appium::Driver.new(caps, true).start_driver
Given(/^I open the app$/) do
@driver.launch_app
end
When(/^I enter valid credentials$/) do
@driver.find_element(:accessibility_id, "username_field").send_keys "testuser"
@driver.find_element(:accessibility_id, "password_field").send_keys "password123"
@driver.find_element(:accessibility_id, "login_button").click
end
Then(/^I should see the dashboard$/) do
expect(@driver.find_element(:accessibility_id, "dashboard").displayed?).to be true
end
Step 6: Run Your Tests Locally and on Sauce Labs
To verify that everything works smoothly:
-
Run tests locally:
cucumber
-
Run tests on Sauce Labs:
Update the cucumber.yml file with your Sauce API credentials and run your tests remotely:
default: -p sauce
sauce:
APP_HOST: "https://ondemand.<region>.saucelabs.com:443/wd/hub"
Then trigger the test run:
cucumber -p sauce
Step 7: Analyze Test Results
After execution, Sauce Labs provides detailed logs, video recordings, and full insights into your Appium test runs. Use these resources to debug faster and ensure your application meets quality standards.
Going Beyond Traditional Testing: Seamless API Testing with AI
While automating iOS apps is an essential part of your Software Development Life Cycle (SDLC), don’t forget about the rest of your app’s ecosystem, especially APIs. Optimize your testing pipeline by complementing mobile automation with API testing powered by AI.
Our RESTful AI tool empowers you to:
- Run cURL requests directly and execute API validation tests instantly.
- Create smart test cases autonomously—without any coding expertise.
- Improve both development and QA workflows by saving time and reducing redundancy.
Let AI-driven tests eliminate the need for manual scripting, so you can focus on delivering great features while maintaining high standards of quality. All it takes is plugging in your cURL request.
Take Action and Automate iOS at Scale
Ready to build quicker, test smarter, and deploy with confidence? Whether you’re a QA expert or a developer stepping into automation for the first time, this guide sets you up for true scalability with iOS testing frameworks like Cucumber, Appium, and Sauce Labs.
And don’t stop there—level up your testing strategy with AI-powered tools that redefine agility. Start today for faster automation and optimized SDLC!