Description
Selenium 4 Grid Slot Matching RFC
Background
A core feature of Selenium 4 Grid is slot matching – the process of pairing a client “new session” request with a node that can satisfy the request. This process involves evaluating the client’s desired capabilities against the stereotypes of available nodes to determine which (if any) matches the request. The default implementation is defined in a class named DefaultSlotMatcher.
Implementation Details of DefaultSlotMatcher
- Step 1: Initial match – evaluate request against defined stereotype values:
- Filter out extension capabilities (names that contain “:”)
- Filter out
platformName
capability - Evaluate stereotype value against desired capability value:
- If desired value is a string, perform case-insensitive comparison…
- … else if desired value is defined, perform object comparison…
- … else ignore capability with undefined desired value
- Step 2: Evaluate managed download capability:
- Match if desired value is undefined or ‘false’…
- … else match if stereotype supports managed downloads
- Step 3: Evaluate
platformVersion
capability:- Evaluate desired capabilities with names containing
platformVersion
- Match if a stereotype capability with identical name has the same value
- Evaluate desired capabilities with names containing
- Step 4: Evaluate request against defined extension capability values:
- Filter out capabilities containing
goog:
,moz:
,ms:
, orse:
- Evaluate stereotype value against desired capability value:
- If desired value is a string, perform case-insensitive comparison…
- … else if desired value is defined, perform object comparison…
- … else ignore capability with undefined desired value
- Filter out capabilities containing
- Step 5: Evaluate
browserName
capability:- Match if desired
browserName
value is undefined or empty - Match if stereotype
browserName
capability has the desired value
- Match if desired
- Step 6: Evaluate
browserVersion
capability:- Match if desired
browserVersion
value is undefined, empty, or “stable” - Match if desired value is equivalent to stereotype
browserVersion
- Match if desired
- Step 7: Evaluate
platformName
capability:- Match if desired
platformName
value is undefined - Match if stereotype
platformName
capability has the desired value - Match if desired value is equivalent to stereotype
platformName
- Match if desired
Current Issue – Extension Capability Handling
As currently implemented, DefaultSlotMatcher has one obvious issue at Step 4 in its handling of extension capabilities. It ignores the extension capabilities of three vendors (Google, Mozilla, and Microsoft), but considers the extension capabilities of every other vendor (including Appium and Apple). This produces inconsistent slot matching behavior, with Appium extension capabilities causing slot matching to fail while similar Google extension capabilities would have no ill effect.
Solution – Capability Type Differentiation
The existing handling of extension capabilities for the three “special” vendors suggests that capabilities might be divided into two distinct categories: “identity” values that are considered for slot matching and configuration options that are transmitted to the matched node without analysis.
Patterns from Current Usage
In current usage, values defined within “options” extension capability objects should be ignored for slot matching (i.e. – configuration options). Two additional extension capabilities are also currently ignored: <prefix>:debuggerAddress
and <prefix>:loggingPrefs
. Every other defined capability for the three “special” vendors is treated as an “identity” value. However, these categories are merely incidental, not formally defined within the specifications. Consequently, there’s no defined mechanism for vendors to add new “identity” values or configuration options.
Proposal: Formally Define Capability Type Differentiation
Formalizing the current implied categorization of capabilities into “identity” values and configuration options will provide two distinct benefits:
- Consistent treatment of extension capabilities will provide consistent behavior for all vendors.
- Defining explicit patterns for “identity” values and configuration options enables each vendor to select the desired treatment for their extension capabilities, allowing them to add new capabilities and options as needed and get the expected handling without the need for custom slot matchers.
Definition of configuration options
The proposed definition for configuration options, which will be ignored for purposes of slot matching:
- Any extension capability with prefix
se:
(Selenium). - Any extension capability with one of the following suffixes:
options
Options
loggingPrefs
debuggerAddress
Definition of “identity” values
All capabilities that don’t conform with the definition of configuration options as defined above will be treated as “identity” values, which will be considered for purposes of slot matching. This includes extension capabilities with “special” prefixes that would previously have been ignored. This change is merely academic, though, given that there are no currently defined “special” extension capabilities that are affected by the revised behavior.
Written with StackEdit.
Usage example
This feature will be implemented in DefaultSlotMatcher. Consequently, anyone using Selenium 4 Grid without explicitly configuring a custom slot matcher will encounter the revised behavior.