Skip to main content
🎉 A11y Issue Detection Agent is now live! Detect accessibility issues like a WCAG expert with AI. Try now!
No Result Found
Connect & Get help from 6000+ developers on our Discord community. Ask the CommunityAsk the Community

Integrate Cucumber - Ruby test suite with App Accessibility testing

Run Cucumber tests using Ruby as a test runner to perform accessibility checks on your app.

BrowserStack App Automate supports running Cucumber tests in Ruby on a wide range of real Android and iOS devices. You can integrate your existing Cucumber + Ruby test suites with BrowserStack to run accessibility checks on your mobile apps using real devices.

For Android devices, automated App Accessibility testing is supported on version 11 and above.

Prerequisites

  • Ensure you have a BrowserStack Username and Access Key. Obtain your userName and accessKey from the Account & Profile section on the dashboard.
    If you have not yet created an account, sign up for a free trial.
  • Ensure you have Ruby 3.2.0 or later installed on your system. To download Ruby, see ruby-lang.org.
  • Ensure you have Bundler installed on your system. To install Bundler, follow the steps outlined in the Bundler installation guide.
  • Access to an Android app (.apk, .aab, or .xapk file) or an iOS app (.ipa file).
  • An existing Cucumber - Ruby test suite for your mobile app.

Integrate your Cucumber - Ruby test suite with App Accessibility testing

Upload your app

Upload your Android app (.apk, .aab, or .xapk file) or iOS app (.ipa file) to BrowserStack servers using REST API.

The following sample cURL command demonstrates how to upload an app:

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/app/file/Application-debug.apk"

A sample response for the request is shown below:

{
    "app_url": "bs://c8ddcb5649a8800075bfd8f151115bba6b3",
    "custom_id": "SampleApp",
    "shareable_id": "tests/SampleApp"
}

Note the app_url value returned in the API response. You will use this value to set the app capability in your test configuration file.

Set your BrowserStack credentials

Save your BrowserStack credentials as environment variables to make it easier to run your test suite from your local or CI environment.

Copy icon Copy
Copy icon Copy

Add the BrowserStack Ruby SDK dependency

  1. Navigate to the Gemfile in your Cucumber - Ruby test suite and add the BrowserStack Ruby SDK dependency:
     gem 'browserstack-ruby-sdk'
    
  2. Install the BrowserStack Ruby SDK and other gems from your Gemfile:
     bundle install
    

Create the browserstack.yml configuration file

Use the BrowserStack Capability Generator to create a browserstack.yml file and save it in the same directory as your Gemfile.
The browserstack.yml configuration file defines the required capabilities to run tests on BrowserStack. If you are testing on both Android and iOS devices, you must create separate configuration files for each platform.

Modify the configuration file

Modify the browserstack.yml file to include the accessibility testing capabilities.

  1. Open the browserstack.yml file.
  2. Set your BrowserStack username and access_key.
  3. Update the app value with the app_url from step 1.
  4. Add the accessibility flag and set its value to true.
  5. Configure the accessibilityOptions property to set various accessibility testing options. For details, see Configuration options.
  6. Save the file.

To auto-generate screen reader testing reports for your app’s workflow, set the screenReaderAutomationReport flag to true under accessibilityOptions.

The project and name config must be static and not change across different runs of the same build. This is a deviation in approach as specified by BrowserStack App Automate since Automated tests will automatically identify different build runs.

browserstack.yml
Copy icon Copy

Run the sample test

From the directory containing your features/ folder, run:

  browserstack-sdk exec cucumber features/<feature-file>.feature

The SDK will automatically use the browserstack.yml file in your current working directory.

To use a different config file, specify it with --browserstackConfigFile:

  browserstack-sdk exec --browserstackConfigFile=<path/to/config/file.yml>

View the accessibility test report

After the test completes, view the report in your project folder on the App Accessibility dashboard.


Visit App Accessibility dashboard

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle