Table of Contents

Class BrowserVersion

Namespace
CSF.Extensions.WebDriver.Identification
Assembly
CSF.Extensions.WebDriver.dll

Base class for a model which describes a WebDriver browser version.

public abstract class BrowserVersion : IEquatable<BrowserVersion>, IComparable<BrowserVersion>
Inheritance
BrowserVersion
Implements
Derived
Inherited Members

Remarks

Browser version instances are comparable and overload the <, >, <= & >= operators. It is easy to quickly compare version instances as if they were numbers.

Concrete implementations of BrowserVersion implement the correct rules of commonly-used version numbering systems, including Semantic Versioning, which will correctly parse the version numbers of most common browsers.

Constructors

BrowserVersion(bool)

Initialises a new instance of BrowserVersion.

protected BrowserVersion(bool isPresumed = false)

Parameters

isPresumed bool

Whether or not this is a presumed version; see IsPresumedVersion.

Properties

IsPresumedVersion

Gets a value indicating whether or not the current instance represents a presumed version or not.

public bool IsPresumedVersion { get; }

Property Value

bool

Remarks

When this property is true, this indicates that we are not sure that the version reported by the current BrowserVersion is accurate. This can be the case when the WebDriver implementation does not report-back its version correctly.

A presumed version is created by using the information from the original WebDriver request (based upon the options used to create the driver). It means "We asked for version X, so we presume that it is version X". Of course, across the many scenarios possible, this might not always be correct.

PresumedSuffix

Gets a suffix for derived types' versions which indicates whether or not IsPresumedVersion is true or not.

protected string PresumedSuffix { get; }

Property Value

string

Methods

CompareTo(BrowserVersion)

public abstract int CompareTo(BrowserVersion other)

Parameters

other BrowserVersion

Returns

int

Create(string, string)

Creates a new instance of BrowserVersion from the specified version received from a WebDriver and the version which was requested via the driver options.

public static BrowserVersion Create(string version, string requestedVersion = null)

Parameters

version string

A browser version string received from a WebDriver

requestedVersion string

An optional browser version string which was 'requested' by inclusion in the WebDriver's creation options.

Returns

BrowserVersion

An implementation of BrowserVersion

Remarks

This method attempts to find the 'best' implementation of BrowserVersion available. It will try SemanticBrowserVersion and then DottedNumericBrowserVersion for both the version and then requestedVersion before it attempts UnrecognisedBrowserVersion with either.

Equals(BrowserVersion)

public abstract bool Equals(BrowserVersion other)

Parameters

other BrowserVersion

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override abstract int GetHashCode()

Returns

int

Operators

operator ==(BrowserVersion, object)

Gets a value indicating whether or not the browser version is equal to the specified object.

public static bool operator ==(BrowserVersion version, object other)

Parameters

version BrowserVersion

A browser version

other object

Another object

Returns

bool

true if the version is equal to the object; false if not.

operator >(BrowserVersion, BrowserVersion)

Gets a value indicating whether or not one browser version is greater than the other.

public static bool operator >(BrowserVersion first, BrowserVersion second)

Parameters

first BrowserVersion

A browser version

second BrowserVersion

A browser version

Returns

bool

true if the first version is greater than the second; false otherwise.

Remarks

If either parameter is null then this operator will return false.

operator >=(BrowserVersion, BrowserVersion)

Gets a value indicating whether or not one browser version is greater than or equal to the other.

public static bool operator >=(BrowserVersion first, BrowserVersion second)

Parameters

first BrowserVersion

A browser version

second BrowserVersion

A browser version

Returns

bool

true if the first version is greater than or equal to the second; false otherwise.

Remarks

If either parameter is null then this operator will return false.

operator !=(BrowserVersion, object)

Gets a value indicating whether or not the browser version is not equal to the specified object.

public static bool operator !=(BrowserVersion version, object other)

Parameters

version BrowserVersion

A browser version

other object

Another object

Returns

bool

true if the version is not equal to the object; false if it is.

operator <(BrowserVersion, BrowserVersion)

Gets a value indicating whether or not one browser version is less than the other.

public static bool operator <(BrowserVersion first, BrowserVersion second)

Parameters

first BrowserVersion

A browser version

second BrowserVersion

A browser version

Returns

bool

true if the first version is less than the second; false otherwise.

Remarks

If either parameter is null then this operator will return false.

operator <=(BrowserVersion, BrowserVersion)

Gets a value indicating whether or not one browser version is less than or equal to the other.

public static bool operator <=(BrowserVersion first, BrowserVersion second)

Parameters

first BrowserVersion

A browser version

second BrowserVersion

A browser version

Returns

bool

true if the first version is less than or equal to the second; false otherwise.

Remarks

If either parameter is null then this operator will return false.