Appium-Capabilities-7 : Complete Details on “appium:options” — (W3C Capabilities)

Get a step-by-step walkthrough in the video below!
In this article, we’ll explore the following key points related to "appium:options"
:
- What is
appium:options
?
Understand the purpose and structure of theappium:options
capability in Appium. - Why Use
appium:options
?
Explore the benefits and use cases of usingappium:options
for cleaner, standardized capability configurations. - Demo: Positive & Negative Scenarios with
appium:options
Execute and analyze both successful and failing test scenarios usingappium:options
to showcase its impact.
What is
appium:options
?
appium:options
is a namespaced capability container introduced to support the W3C WebDriver standard, which requires vendor-specific capabilities to be grouped under a namespaced key.
It encapsulates all Appium-specific capabilities, including those that are:
- Common (across platforms)
- Android-specific
- iOS-specific
- Driver-specific (UiAutomator2, XCUITest, Espresso, etc.)
Why Use
appium:options
?
- W3C WebDriver compliant
- Avoids capability clashes
- Cleaner structure and better validation
Step 1: Create a map for appium:options
Map<String,Object> appiumOptions=new HashMap<>();
appiumOptions.put("platformVersion", "13");
appiumOptions.put("automationName", "uiautomator2");
appiumOptions.put("deviceName", "Pixel6");
appiumOptions.put("app", apkpath);
appiumOptions.put("noReset", true);
appiumOptions.put("autoGrantPermissions", true);
appiumOptions.put("newCommandTimeout", 120);
Example:

Step 2: Wrap appium options inside Capabilities
UiAutomator2Options cap=new UiAutomator2Options();
//PlatformName at root-level
cap.setPlatformName("android");
//Step 2: Wrap appium options inside Capabilities
cap.setCapability("appium:options", appiumOptions);
driver = new AndroidDriver(new URL("http://127.0.0.1:4723"), cap);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(100));
Example:

Why Is platformName Outside appium:options?
platformName is defined by the W3C as a standard capability,
so it must not be vendor-namespaced like appium:options.
Mixing W3C and Non-W3C
You can still mix platformName
at the root level and others inside appium:options
:
{
"platformName": "Android",
"appium:options": {
"automationName": "uiautomator2",
"deviceName": "emulator-5554",
"platformVersion": "11.0",
"app": "/path/to/app.apk",
"noReset": true
}
}
Example: appium-config.json

Scenario: When the
"platformName"
capability is defined inside"appium:options"
, observe the following impact:
Script:

Impact: Session will not created.

Summary Points:

GitHub Link:
π¬ Explore More! Watch My Latest Videos on YouTube!
Visit My Official Blog:
No comments:
Post a Comment