buttons

Appium CLI — Creating an Appium Config File in “JSON” format(Step-by-Step) & With Field-by-Field Explanation

 

Appium CLI — Creating an Appium Config File in “JSON” format(Step-by-Step) & With Field-by-Field Explanation

Get a step-by-step walkthrough in the video below!

What is Appium configuration file?

— Used to simplify running Appium server with predefined settings.

This file allows you to configure server arguments like ports, drivers, plugins, and log settings in one place.

πŸ”Ή Step 1: Understand the Appium Config File Purpose

Appium config files let you:

  • Predefine server settings like port, host, base-path
  • Set drivers and plugins
  • Define log level and log file
  • Avoid passing long command-line arguments

πŸ”Ή Step 2: Choose a File Format

Appium supports:

  • JSON (preferred)
  • YAML (also supported)
  • Js(javascript)

Use .json for cross-platform consistency.

πŸ”Ή Step 3: Create a JSON Config File

Create a file named appium-config.json.

https://github.com/AppiumGuide/AppiumGuide/blob/main/config_files/appium-config.json

Step-by-Step Breakdown of “appium-config.json” file:

πŸ”Ή Step 1: Root Structure

The config file is divided into 3 major sections:

  • “server” — Appium server settings
  • “driver” — Mobile automation drivers (e.g., uiautomator2, xcuitest)
  • “plugin” — Appium plugins to enhance functionality

πŸ”Ή Step 2: “server” Block

"server": {
"port": 4723,
"host": "0.0.0.0",
"basePath": "/wd/hub",
"logLevel": "info",
"logFile": "./logs/appium.log",
"relaxedSecurityEnabled": true,
"allowCors": true,
"useDrivers": ["uiautomator2", "xcuitest"],
"usePlugins": ["element-wait"]
}

πŸ”Έ Field-by-Field Explanation:

Key → Purpose

port → Port where Appium server will listen (default: 4723)

host → Host address (0.0.0.0 means listen on all interfaces)

basePath → WebDriver URL path (/ is standard)

logLevel → Verbosity of logs (info, debug, warn, etc.)

logFile → Path to store server logs (./logs/appium.log)

relaxedSecurityEnabled → Allows unsafe features like file upload, shell access (for advanced usage)

allowCors → Enables cross-origin requests for Appium server UI

useDrivers → Preloads the listed drivers at startup (Android & iOS)

usePlugins → Preloads plugins, here element-wait is activated

πŸ”Ή Step 3: “driver” Block

"driver": {
"uiautomator2": {
"version": "latest"
},
"xcuitest": {
"version": "latest"
}
}

πŸ”Έ Purpose:

Defines which versions of the mobile drivers to load.

πŸ”Ή Step 4: “plugins” Block

"plugin": {
"images": {
"active": true
}
}

πŸ”Έ Purpose:

Activates Appium plugins for enhanced functionality.

πŸ”Ή Step 5: Running with This Config

Once saved, start Appium with:

appium --config \path\appium-config.json
Press enter or click to view image in full size

Example:

Compare the values between appium logs Vs appium-config.json

No comments:

Post a Comment