Skip to content
Tutorials Center
My learning

Topics

Lesson 23 of 35 ยท Browsers and Scale

Cloud Providers and Mobile with Appium

Run Selenium tests on vendor clouds and test mobile apps with Appium: remote execution, W3C capabilities, vendor options, costs and when each choice makes sense.

A Grid you run yourself gives you control, but it also gives you chores: updating browsers, keeping machines healthy and owning every crash. Two things usually push teams to look elsewhere. First, coverage: you may need Safari on a Mac, old Windows versions or dozens of real phones, and you do not want a device lab in the office. Second, scale: a release deadline might need 200 sessions for an hour, not for the whole year. Cloud testing providers rent browsers and devices by the minute or by parallel slot. Appium extends the WebDriver idea from web browsers to native mobile apps. This lesson explains how both fit into what you already know.

Cloud accounts, phones and Appium servers cannot run on this site, so all vendor and Appium code is read-only and deliberately generic: no vendor names are required, and capability keys such as vendor:options are placeholders. Look up the exact keys in your provider's documentation. The runnable examples are stand-ins that build capabilities and compare costs; the cost numbers are invented for teaching.

Where can sessions run?

Local Your machine. Simple, one browser.
Own Grid Your servers. Full control, your chores.
Cloud Rented browsers and devices.

The test code stays almost the same in all three.

1 / 2

Remote execution on a vendor cloud

From the previous lesson you know the pattern: a Grid is just a different address in Remote. A cloud provider offers a Grid-compatible endpoint that you reach over HTTPS. Your test still builds options and creates a webdriver.Remote; what changes is the URL and a few extra capabilities.

Python
# read-only: the shape of a cloud session (placeholders, not a real vendor)
import os
from selenium import webdriver

options = webdriver.ChromeOptions()
options.browser_version = "latest"
options.platform_name = "Windows 11"
options.set_capability("vendor:options", {
    "projectName": "shop-regression",
    "buildName": os.environ.get("BUILD_NUMBER", "local"),
    "sessionName": "login works",
})

user = os.environ["CLOUD_USER"]
key = os.environ["CLOUD_KEY"]
driver = webdriver.Remote(
    command_executor=f"https://{user}:{key}@hub.cloud-provider.test/wd/hub",
    options=options,
)

Three details are worth noticing:

  1. Standard capabilities (browserName, browserVersion, platformName) say which browser and operating system you want. They are the same names used for a self-hosted Grid.
  2. Vendor capabilities use a prefix with a colon, as the W3C standard requires, and hold everything provider specific: build and test names that appear in the dashboard, video recording, network logs, tunnels and so on. The names differ from vendor to vendor.
  3. Credentials come from the environment, never from the source file. Anyone who can read the repository could otherwise spend your account's minutes. See Test Data and Configuration and Security, Ethics and Scraping Limits.

Many providers also give you a dashboard with a video and logs per session, which is valuable when a test fails only on one operating system. Some give a tunnel: a small program that lets cloud browsers reach a site on your private network, such as a staging server not visible on the public internet. Without a tunnel, a cloud browser cannot open http://localhost:3000, because "localhost" would mean the cloud machine, not yours.

What to ask before choosing

  • Which browsers, versions and operating systems do you need, and does the provider offer real devices or only emulators?
  • How many parallel sessions does the plan include, and what happens when you ask for more (queue, error or extra fee)?
  • How is it billed: per minute, per parallel slot or per user?
  • Can it reach your private staging site, and how (tunnel, allow-listed addresses)?
  • What do you get after a failure: video, screenshots, console and network logs, retained for how long?
  • Where does your test data go? Never run tests with real customer data on rented machines.

Why mobile needs more than a browser

A browser on a phone is still a browser, and Selenium can drive many of them through the same protocol. A native app is different: it has no URL, no DOM and no CSS. It has screens built by the operating system with their own element trees, gestures such as swipe and long press, permissions dialogs and a hardware back button.

Appium is the open source project that speaks the WebDriver protocol for these apps. Your test uses a client library that looks very much like Selenium and sends commands to an Appium server, which translates them for a driver that controls the device: for Android, the UiAutomator2 driver; for iOS, the XCUITest driver. Appium 2 keeps the server small and installs drivers as plugins. It listens on port 4723 by default.

flowchart LR
  T["Test script<br/>Appium client"] -->|"W3C commands"| S["Appium server"]
  S --> A["UiAutomator2 driver"]
  S --> I["XCUITest driver"]
  A --> P1["Android phone or emulator"]
  I --> P2["iPhone or simulator"]

The same W3C protocol reaches different platform drivers through the Appium server.

The relationship with Selenium is a family one: both implement the WebDriver idea, Appium's client libraries extend Selenium's ones, and a cloud provider's endpoint often accepts both web and app sessions. A first Appium script in Python looks like this:

Python
# read-only
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy

options = UiAutomator2Options()
options.platform_name = "Android"
options.device_name = "Pixel_emulator"
options.app = "/builds/shop-debug.apk"

driver = webdriver.Remote("http://127.0.0.1:4723", options=options)
driver.find_element(AppiumBy.ACCESSIBILITY_ID, "Login").click()
driver.quit()

Locators resemble the web ones: an accessibility id is the closest thing to a test id (developers set it on the element, and it doubles as the label read by screen readers), AppiumBy.ID uses the platform resource id, and XPath works but is slower and brittle on mobile. The same advice from Choosing Stable Locators applies: ask developers for stable identifiers.

Appium specific capabilities need the appium: prefix (for example appium:automationName, appium:deviceName, appium:app), because only a few names are standard. The client option classes add the prefix for you, but you will see it in logs and in raw JSON.

The first stand-in builds capabilities for a cloud web session and an Appium session and checks that every non-standard key carries a vendor prefix, which is exactly the mistake that makes real servers reject a request.

JS W3C capability prefixes

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Costs and trade-offs

There is no universally best choice. The trade-off is easier to think about with numbers, so the second stand-in compares the monthly cost of a small self-hosted setup with a pay-per-slot cloud plan. The prices are invented to show the shape of the calculation; use your own quotes.

JS Self-hosted or cloud? A cost sketch

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The sketch makes one point: the real cost is not only the invoice. Maintenance hours and the time a team waits for results count too. Typical guidance:

  • Small team, few browsers: local runs plus a standalone Docker browser in CI.
  • Many parallel runs, mostly Chrome and Firefox: a self-hosted Grid on rented servers.
  • Safari, old operating systems or real devices: a cloud provider for those cases, while the bulk of tests keep running cheaply elsewhere.
  • Mobile apps: start with emulators and simulators for fast feedback, and add real devices for the flows that depend on hardware, such as camera, push notifications and the real keyboard.

Since every environment uses the same standard commands, you can mix them. The driver factory decides from configuration (an environment variable such as TEST_TARGET=local|grid|cloud) where to run, and tests never know. That design is the topic of Project: A Small Test Framework.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the main change in a test when it moves from a local driver to a cloud provider?

    Commands stay the same. The driver connects to a remote endpoint, and provider specific settings go in prefixed capabilities.
  2. 2. Why do credentials for a cloud account belong in environment variables?

    Secrets in source code leak through version control. Reading them from the environment keeps them out of the repository.
  3. 3. What does Appium add compared with Selenium for browsers?

    Appium implements the WebDriver idea for native apps, using platform drivers such as UiAutomator2 and XCUITest.
  4. 4. Why does a cloud browser fail to open http://localhost:3000 from your machine?

    The browser runs on the provider's machine, so localhost points there. A tunnel makes your private site reachable.
  5. 5. Which capability name is a correct Appium specific capability?

    Capabilities that are not part of the W3C standard need a vendor prefix with a colon, so Appium uses the appium: prefix.

Summary

  • Cloud providers expose Grid compatible endpoints: use Remote, standard capabilities for browser and system, and prefixed vendor capabilities for provider features.
  • Keep credentials in environment variables, ask about parallel slots, real devices, tunnels and artifacts before choosing, and never test with real customer data.
  • Appium brings WebDriver style automation to native apps through platform drivers; its non-standard capabilities use the appium: prefix, and accessibility ids are the stable locators.
  • Compare options by total cost, including maintenance and waiting time, and mix environments behind one driver factory.

Next: Flaky Tests and Debugging