A base class representing a driver for a web browser.
public class WebDriver : IWebDriver, IDisposable, ISearchContext, IJavaScriptExecutor, IFindsElement, ITakesScreenshot, ISupportsPrint, IActionExecutor, IAllowsFileDetection, IHasCapabilities, IHasCommandExecutor, IHasSessionId, ICustomDriverCommandExecutor, IHasVirtualAuthenticator
WebDriver
Initializes a new instance of the WebDriver class.
protected WebDriver(ICommandExecutor executor, ICapabilities capabilities)
Parameters
executor
ICommandExecutor
The ICommandExecutor object used to execute commands.
capabilities
ICapabilities
The ICapabilities object used to configure the driver session.
The default command timeout for HTTP requests in a RemoteWebDriver instance.
protected static readonly TimeSpan DefaultCommandTimeout
Field Value
Gets the cached virtual authenticator ID, or null if no authenticator ID is set.
public string? AuthenticatorId { get; }
Property Value
Gets the ICapabilities that the driver session was created with, which may be different from those requested.
public ICapabilities Capabilities { get; }
Property Value
Gets the ICommandExecutor which executes commands for this driver.
public ICommandExecutor CommandExecutor { get; }
Property Value
Gets the current window handle, which is an opaque handle to this window that uniquely identifies it within this driver instance.
public string CurrentWindowHandle { get; }
Property Value
Gets or sets the factory object used to create instances of WebElement or its subclasses.
protected WebElementFactory ElementFactory { get; set; }
Property Value
If value is set to null.
Gets or sets the IFileDetector responsible for detecting sequences of keystrokes representing file paths and names.
public virtual IFileDetector FileDetector { get; set; }
Property Value
If value is set to null.
Gets a value indicating whether this object is a valid action executor.
public bool IsActionExecutor { get; }
Property Value
Gets the source of the page last loaded by the browser.
public string PageSource { get; }
Property Value
Gets the SessionId for the current session of this driver.
public SessionId SessionId { get; }
Property Value
Gets the title of the current browser window.
public string Title { get; }
Property Value
Gets or sets the URL the browser is currently displaying.
public string Url { get; set; }
Property Value
Gets the window handles of open browser windows.
public ReadOnlyCollection<string> WindowHandles { get; }
Property Value
Add a credential to the Virtual Authenticator/
public void AddCredential(Credential credential)
Parameters
credential
Credential
The credential to be stored in the Virtual Authenticator
If credential
is null.
If a Virtual Authenticator has not been added yet.
Creates a Virtual Authenticator.
public string AddVirtualAuthenticator(VirtualAuthenticatorOptions options)
Parameters
options
VirtualAuthenticatorOptions
Authenticator id as string
If options
is null.
Closes the Browser
Dispose()Dispose the WebDriver Instance
Dispose(bool)Stops the client from running
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
if its in the process of disposing
Executes a command with this driver.
protected virtual Response Execute(string driverCommandToExecute, Dictionary<string, object>? parameters)
Parameters
driverCommandToExecute
string
A DriverCommand value representing the command to execute.
parameters
Dictionary<string, object>
A Dictionary<TKey, TValue> containing the names and values of the parameters of the command.
A Response containing information about the success or failure of the command and any data returned by the command.
If driverCommandToExecute
is null.
Executes a command with this driver.
protected virtual Task<Response> ExecuteAsync(string driverCommandToExecute, Dictionary<string, object>? parameters)
Parameters
driverCommandToExecute
string
A DriverCommand value representing the command to execute.
parameters
Dictionary<string, object>
A Dictionary<TKey, TValue> containing the names and values of the parameters of the command.
A Response containing information about the success or failure of the command and any data returned by the command.
If driverCommandToExecute
is null.
Executes JavaScript "asynchronously" in the context of the currently selected frame or window, executing the callback function specified as the last argument in the list of arguments.
public object? ExecuteAsyncScript(string script, params object?[]? args)
Parameters
script
string
The JavaScript code to execute.
args
object[]
The arguments to the script.
The value returned by the script.
Executes a command with this driver.
public object? ExecuteCustomDriverCommand(string driverCommandToExecute, Dictionary<string, object> parameters)
Parameters
driverCommandToExecute
string
The name of the command to execute. The command name must be registered with the command executor, and must not be a command name known to this driver type.
parameters
Dictionary<string, object>
A Dictionary<TKey, TValue> containing the names and values of the parameters of the command.
A Response containing information about the success or failure of the command and any data returned by the command.
The command returned an exceptional value.
Executes JavaScript in the context of the currently selected frame or window
public object? ExecuteScript(PinnedScript script, params object?[]? args)
Parameters
script
PinnedScript
A PinnedScript object containing the JavaScript code to execute.
args
object[]
The arguments to the script.
The value returned by the script.
If script
is null.
Executes JavaScript in the context of the currently selected frame or window
public object? ExecuteScript(string script, params object?[]? args)
Parameters
script
string
The JavaScript code to execute.
args
object[]
The arguments to the script.
The value returned by the script.
Executes JavaScript in the context of the currently selected frame or window using a specific command.
protected object? ExecuteScriptCommand(string script, string commandName, params object?[]? args)
Parameters
script
string
The JavaScript code to execute.
commandName
string
The name of the command to execute.
args
object[]
The arguments to the script.
The value returned by the script.
Finds the first element in the page that matches the By object
public IWebElement FindElement(By by)
Parameters
by
By
By mechanism to find the object
IWebElement object so that you can interact with that object
IWebDriver driver = new InternetExplorerDriver();
IWebElement elem = driver.FindElement(By.Name("q"));
Exceptions
If by
is null.
Finds an element matching the given mechanism and value.
public virtual IWebElement FindElement(string mechanism, string value)
Parameters
mechanism
string
The mechanism by which to find the element.
value
string
The value to use to search for the element.
The first IWebElement matching the given criteria.
Finds the elements on the page by using the By object and returns a ReadOnlyCollection of the Elements on the page
public ReadOnlyCollection<IWebElement> FindElements(By by)
Parameters
by
By
By mechanism to find the element
ReadOnlyCollection of IWebElement
IWebDriver driver = new InternetExplorerDriver();
ReadOnlyCollection<IWebElement> classList = driver.FindElements(By.ClassName("class"));
FindElements(string, string)
Finds all elements matching the given mechanism and value.
public virtual ReadOnlyCollection<IWebElement> FindElements(string mechanism, string value)
Parameters
mechanism
string
The mechanism by which to find the elements.
value
string
The value to use to search for the elements.
A collection of all of the IWebElements matching the given criteria.
Gets the capabilities as a dictionary.
protected virtual Dictionary<string, object> GetCapabilitiesDictionary(ICapabilities capabilitiesToConvert)
Parameters
capabilitiesToConvert
ICapabilities
The dictionary to return.
A Dictionary consisting of the capabilities requested.
If capabilitiesToConvert
is null.
Retrieves all the credentials stored in the Virtual Authenticator
public List<Credential> GetCredentials()
Returns
List of credentials
If a Virtual Authenticator has not been added yet.
Gets a Screenshot object representing the image of the page on the screen.
public Screenshot GetScreenshot()
Returns
A Screenshot object containing the image.
Instructs the driver to change its settings.
ReturnsAn IOptions object allowing the user to change the settings of the driver.
Instructs the driver to navigate the browser to another location.
public INavigation Navigate()
Returns
An INavigation object allowing the user to access the browser's history and to navigate to a given URL.
Performs the specified list of actions with this action executor.
public void PerformActions(IList<ActionSequence> actionSequenceList)
Parameters
actionSequenceList
IList<ActionSequence>
The list of action sequences to perform.
Gets a PrintDocument object representing a PDF-formatted print representation of the page.
public PrintDocument Print(PrintOptions printOptions)
Parameters
printOptions
PrintOptions
A PrintOptions object describing the options of the printed document.
The PrintDocument object containing the PDF-formatted print representation of the page.
If printOptions
is null.
Close the Browser and Dispose of WebDriver
RegisterCustomDriverCommand(string, CommandInfo?)Registers a command to be executed with this driver instance.
public bool RegisterCustomDriverCommand(string commandName, CommandInfo? commandInfo)
Parameters
commandName
string
The unique name of the command to register.
commandInfo
CommandInfo
The CommandInfo object describing the command.
Registers a set of commands to be executed with this driver instance.
public void RegisterCustomDriverCommands(IReadOnlyDictionary<string, CommandInfo> commands)
Parameters
commands
IReadOnlyDictionary<string, CommandInfo>
An IReadOnlyDictionary<TKey, TValue> where the keys are the names of the commands to register, and the values are the CommandInfo objects describing the commands.
Registers a command to be executed with this driver instance as an internally known driver command.
protected bool RegisterInternalDriverCommand(string commandName, CommandInfo? commandInfo)
Parameters
commandName
string
The unique name of the command to register.
commandInfo
CommandInfo
The CommandInfo object describing the command.
Removes all the credentials stored in the Virtual Authenticator.
public void RemoveAllCredentials()
Exceptions
If a Virtual Authenticator has not been added yet.
Removes the credential identified by the credentialId from the Virtual Authenticator.
public void RemoveCredential(byte[] credentialId)
Parameters
credentialId
byte[]
The id as byte array that uniquely identifies a credential
If credentialId
is null.
If a Virtual Authenticator has not been added yet.
Removes the credential identified by the credentialId from the Virtual Authenticator.
public void RemoveCredential(string credentialId)
Parameters
credentialId
string
The id as string that uniquely identifies a credential
If credentialId
is null.
If a Virtual Authenticator has not been added yet.
Removes the Virtual Authenticator
public void RemoveVirtualAuthenticator(string authenticatorId)
Parameters
authenticatorId
string
Id as string that uniquely identifies a Virtual Authenticator.
If authenticatorId
is null.
Resets the input state of the action executor.
public void ResetInputState()
SetUserVerified(bool)
Sets the isUserVerified property for the Virtual Authenticator.
public void SetUserVerified(bool verified)
Parameters
verified
bool
The boolean value representing value to be set
Starts a session with the driver
protected void StartSession(ICapabilities capabilities)
Parameters
capabilities
ICapabilities
Capabilities of the browser
Method to give you access to switch frames and windows
public ITargetLocator SwitchTo()
Returns
Returns an Object that allows you to Switch Frames and Windows
IWebDriver driver = new InternetExplorerDriver();
driver.SwitchTo().Frame("FrameName");
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4