Table of Contents

Class SeleniumHelper

Namespace
SunamoSelenium
Assembly
SunamoSelenium.dll

Helper class for initializing and managing Selenium WebDriver instances.

public class SeleniumHelper
Inheritance
SeleniumHelper
Inherited Members
Extension Methods

Methods

InitChromeDriver(ILogger, ChromeOptions?, bool)

Initializes a Chrome WebDriver instance using built-in Selenium Manager (Selenium 4.6+) for automatic driver download and management. After initialization, register the driver via ServiceCollection.AddSingleton(typeof(IWebDriver), driver).

public static Task<IWebDriver?> InitChromeDriver(ILogger logger, ChromeOptions? options = null, bool isThrowingException = false)

Parameters

logger ILogger

The logger instance for diagnostic output.

options ChromeOptions

Optional Chrome browser options. If null, default options are created.

isThrowingException bool

When true, throws an exception on failure instead of returning null.

Returns

Task<IWebDriver>

An initialized OpenQA.Selenium.IWebDriver instance or null on failure.

InitDriver(ILogger, EdgeOptions?, bool)

Alias for InitEdgeDriver(ILogger, EdgeOptions?, bool) for backward compatibility. Initializes Edge WebDriver using built-in Selenium Manager (automatic driver download).

public static Task<IWebDriver?> InitDriver(ILogger logger, EdgeOptions? options = null, bool isThrowingException = false)

Parameters

logger ILogger

The logger instance for diagnostic output.

options EdgeOptions

Optional Edge browser options.

isThrowingException bool

When true, throws an exception on failure instead of returning null.

Returns

Task<IWebDriver>

An initialized OpenQA.Selenium.IWebDriver instance or null on failure.

InitEdgeDriver(ILogger, EdgeOptions?, bool)

Initializes an Edge WebDriver instance using built-in Selenium Manager (Selenium 4.6+) for automatic driver download and management. After initialization, register the driver via ServiceCollection.AddSingleton(typeof(IWebDriver), driver).

public static Task<IWebDriver?> InitEdgeDriver(ILogger logger, EdgeOptions? options = null, bool isThrowingException = false)

Parameters

logger ILogger

The logger instance for diagnostic output.

options EdgeOptions

Optional Edge browser options. If null, default options are created.

isThrowingException bool

When true, throws an exception on failure instead of returning null.

Returns

Task<IWebDriver>

An initialized OpenQA.Selenium.IWebDriver instance or null on failure.

InitEdgeDriver(ILogger, string, EdgeOptions?, bool)

OBSOLETE: Do NOT use hardcoded driver paths. This method throws an exception. Always use Selenium Manager for automatic driver management by calling InitEdgeDriver(ILogger, EdgeOptions?, bool) without path parameter.

[Obsolete("Do NOT use hardcoded driver paths! Use InitEdgeDriver(logger, options) without driverPath parameter. Selenium Manager will automatically download the correct driver version.", true)]
public static Task<IWebDriver?> InitEdgeDriver(ILogger logger, string driverPath, EdgeOptions? options = null, bool isThrowingException = false)

Parameters

logger ILogger

The logger instance for diagnostic output.

driverPath string

The hardcoded driver path (not supported).

options EdgeOptions

Optional Edge browser options.

isThrowingException bool

When true, throws an exception on failure instead of returning null.

Returns

Task<IWebDriver>

Never returns; always throws InvalidOperationException.

OpenChromeDriverDownloadPage()

Opens the ChromeDriver download page in the default browser.

public static void OpenChromeDriverDownloadPage()

OpenEdgeDriverDownloadPage()

Opens the EdgeDriver download page in the default browser.

public static void OpenEdgeDriverDownloadPage()