Skip to content

BrowserFlagsConfiguration

Craig Fowler edited this page Mar 26, 2019 · 3 revisions

Here is an example of the browser flags format, which is a simple JSON format.

[
  {
    "browserName": "Safari",
    "minVersion": "11",
    "flags": [
      "My custom flag",
      "Different flag"
    ]
  }
]

A single flags definition file may contain many elements, like the one shown above. The flags mechanism, when used from a Web Driver Factory, will detect the identification of the browser and sign the appropriate flags matching:

  • The browser name (or names)
  • A minimum and/or maximum version
  • An OS platform

More information is available by reading the documentation comments upon the FlagsDefinition type.

Best practices for using flags

Avoid using "Removal"

Avoid writing flags definition files which rely heavily on removing flags, and certainly avoid open-ended version ranges which remove flags.

Flags are removed after all flags have been added, which means that a removed flag will always override an added flag. Removed flags are a mechanism to allow a hand-crafted definitions file to override a compiled set of definitions (perhaps embedded into an assembly as a resource). This may be neccesary if a new browser version is released to which a flag no longer applies, but the compiled/curated flags definitions have not yet been updated.

Name flags for behaviours, not browsers

The names of flags should describe a browser behaviour, such as MustSendCtrlClickForHtmlSelectMultiple. Some browsers accept a click in order to select/deselect single options within a <select multiple>, wheras others require a modifier key to be pressed to deal with single options. Do not name flags after the browser, such as IsInternetExplorer10; this limits the usefulness of the flag.

Avoid duplicating capabilities

Beware of creating flags which are already handled by browser capabilities. The capabilities mechanism is OK for handling all of the information which it currently handles. The purpose of flags is to be able to retain arbitrary data. Many implementations of IHasCapabilities will not permit the addition of arbitrary/unsupported capabilities, which is why flags were created.

WebBrowserFlags

Clone this wiki locally