buttons

[Appium Parallel Testing] Using Grid4 [Part-1] — How To Configure Selenium Grid 4 with Appium

 

[Appium Parallel Testing] Using Grid4 [Part-1] — How To Configure Selenium Grid 4 with Appium

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

Introduction

In mobile automation, running parallel tests across multiple devices or emulators is essential. Appium combined with Selenium Grid 4 enables us to scale tests efficiently. While Selenium Grid 3 was previously used with Appium, Selenium Grid 4 introduces a modern architecture and easier node registration mechanisms.

In this article, you’ll learn how to configure Selenium Grid 4 with Appium, including comparisons with Grid 3, setting up the environment, and a full breakdown of the architecture.

Topic-1: Download Selenium Grid 4

Topic-2: Appium with Selenium Grid 3

Topic-3: Appium with Selenium Grid 4

Topic-4: Appium Grid Architecture

1. Configuring Grid 4 for Appium — Explain Step-by-Step

2. Register Appium with Grid4

3. Verify Grid Console

Topic-5: Demo

  • Go to the official Selenium site.
  • Download the latest selenium-server-x.y.z.jar file (e.g., selenium-server-4.34.0.jar).

Note: Deprecated, but still used in legacy systems

In Selenium Grid 3:

  • hub and nodes architecture was used.
  • Appium servers were manually registered using a JSON nodeConfig.

Example command: — Configuring Grid 3 for Appium:

Command Used to Start Hub:

java -jar selenium-server-<version>.jar hub

Example:
java -jar selenium-server-4.33.0.jar hub

Command to Configure Nodes:

appium --port <port_no> --nodeconfig <path\node.json

Example:
appium --port 4725 --nodeconfig node1.json

appium --port 4723 --nodeconfig node1.json

Recommended for modern projects — supports distributed, flexible configuration

Major Improvements in Grid 4:

  • Uses TOML configuration files.
  • Auto-detects drivers (e.g., ChromeDriver).
  • Built-in event busdistributed modeDocker support, etc.
  • The Router handles incoming WebDriver requests.
  • The Distributor assigns sessions to available nodes.
  • Nodes are where Appium servers are running.
  1. Configuring Grid 4 for Appium — Explain Step-by-Step
[server]
port = 4444

[node]
detect-drivers = false

[relay]
url = "http://localhost:4723/wd/hub"
status-endpoint = "/status"
#se
configs = [
"1", "{\"browserName\": \"chrome\", \"platformName\": \"android\", \"appium:platformVersion\": \"12\"}",
"1", "{\"browserName\": \"safari\", \"platformName\": \"iOS\", \"appium:platformVersion\": \"12.1\"}"
]

Full File Overview:

This file configures a Selenium Grid Node that relays requests to an Appium server running locally on port 4723.

Section Purpose

[server] → Configures the node’s own port (not Appium)

[node] → Prevents auto-detecting local browser drivers

[relay] → Forwards Selenium Grid requests to your Appium server

configs → Defines what kind of sessions this node can run

🔹 [server] Section

[server]

port = 4444

  • port = 4444: Sets the port where the Selenium node itself will run (not the Grid hub). This is typically used if this node acts as a standalone or for internal communication. If you’re using this with the Grid Hub (usually on port 4444), it’s often fine.

🔹 [node] Section

[node]

detect-drivers = false

  • detect-drivers = false: Tells Selenium not to auto-detect any browser drivers (like ChromeDriver, GeckoDriver).
  • This is important when you’re not using traditional browsers directly but instead relaying to Appium, which manages the devices.

🔹 [relay] Section

[relay]

url = “http://localhost:4723/wd/hub"

status-endpoint = “/status”

  • url: The Appium server’s endpoint to which requests will be forwarded.
  • Here, Appium is running locally on port 4723.
  • status-endpoint: Path to check the node’s status (standard for Appium).

🔹 configs Array

configs = [

“1”, “{\”browserName\”: \”chrome\”, \”platformName\”: \”android\”, \”appium:platformVersion\”: \”12\”}”,

“1”, “{\”browserName\”: \”safari\”, \”platformName\”: \”iOS\”, \”appium:platformVersion\”: \”12.1\”}”

]

This defines the capabilities that the Appium node supports.

Each config has:

  • “1” → Indicates the max number of concurrent sessions for that capability.
  • JSON string describing the Appium desired capabilities.

So:

  1. This node can handle 1 session for Android Chrome on version 12
  2. And 1 session for Android Chrome on version 12.1

These capabilities must match what your emulator or device supports and what your Appium server can handle.

Summary:

Section Purpose

[server] — Configures the node’s own port (not Appium)

[node] — Prevents auto-detecting local browser drivers

[relay] — Forwards Selenium Grid requests to your Appium server

configs — Defines what kind of sessions this node can run

2. Register Appium with Grid4

java -jar selenium-server-4.34.0.jar standalone --config samplenode.toml

Example:

3. Verify Grid Console

Open http://localhost:4444/ui
You should see the Appium node registered with 2 slot.

No comments:

Post a Comment