MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / create_matches

Function create_matches

py/selenium/webdriver/remote/webdriver.py:213–235  ·  view source on GitHub ↗
(options: list[BaseOptions])

Source from the content-addressed store, hash-verified

211
212
213def create_matches(options: list[BaseOptions]) -> dict:
214 capabilities: dict[str, Any] = {"capabilities": {}}
215 opts = [opt.to_capabilities() for opt in options]
216
217 # alwaysMatch holds only the capabilities that are present with an identical value in
218 # *every* option set; everything else stays in the per-option firstMatch entries. A
219 # candidate key must appear in every set, so it must appear in the first one; values
220 # may be dicts/lists and so are compared with ``==`` rather than placed in a set
221 # (see https://bugs.python.org/issue38210).
222 always: dict[str, Any] = {}
223 if opts:
224 for key, value in opts[0].items():
225 if all(key in opt and opt[key] == value for opt in opts[1:]):
226 always[key] = value
227
228 for opt_dict in opts:
229 for key in always:
230 del opt_dict[key]
231
232 capabilities["capabilities"]["alwaysMatch"] = always
233 capabilities["capabilities"]["firstMatch"] = opts
234
235 return capabilities
236
237
238_P = ParamSpec("_P")

Callers 1

__init__Method · 0.85

Calls 2

itemsMethod · 0.80
to_capabilitiesMethod · 0.45

Tested by

no test coverage detected