Class ChromeDriver
Provides a mechanism to write tests against Chrome
public class ChromeDriver : ChromiumDriver, IWebDriver, IDisposable, ISearchContext, IJavaScriptExecutor, IFindsElement, ITakesScreenshot, ISupportsPrint, IActionExecutor, IAllowsFileDetection, IHasCapabilities, IHasCommandExecutor, IHasSessionId, ICustomDriverCommandExecutor, IHasVirtualAuthenticator, ISupportsLogs, IDevTools
- Inheritance
-
ChromeDriver
- Implements
- Inherited Members
- Extension Methods
Examples
[TestFixture]
public class Testing
{
private IWebDriver driver;
[SetUp]
public void SetUp()
{
driver = new ChromeDriver();
}
[Test]
public void TestGoogle()
{
driver.Navigate().GoToUrl("http://www.google.co.uk");
/*
* Rest of the test
*/
}
[TearDown]
public void TearDown()
{
driver.Quit();
}
}
Constructors
ChromeDriver()
Initializes a new instance of the ChromeDriver class.
public ChromeDriver()
ChromeDriver(ChromeDriverService)
Initializes a new instance of the ChromeDriver class using the specified driver service.
public ChromeDriver(ChromeDriverService service)
Parameters
service
ChromeDriverServiceThe ChromeDriverService used to initialize the driver.
ChromeDriver(ChromeDriverService, ChromeOptions)
Initializes a new instance of the ChromeDriver class using the specified ChromeDriverService and options.
public ChromeDriver(ChromeDriverService service, ChromeOptions options)
Parameters
service
ChromeDriverServiceThe ChromeDriverService to use.
options
ChromeOptionsThe ChromeOptions used to initialize the driver.
ChromeDriver(ChromeDriverService, ChromeOptions, TimeSpan)
Initializes a new instance of the ChromeDriver class using the specified ChromeDriverService.
public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
Parameters
service
ChromeDriverServiceThe ChromeDriverService to use.
options
ChromeOptionsThe ChromeOptions to be used with the Chrome driver.
commandTimeout
TimeSpanThe maximum amount of time to wait for each command.
ChromeDriver(ChromeOptions)
Initializes a new instance of the ChromeDriver class using the specified options.
public ChromeDriver(ChromeOptions options)
Parameters
options
ChromeOptionsThe ChromeOptions to be used with the Chrome driver.
ChromeDriver(string)
Initializes a new instance of the ChromeDriver class using the specified path to the directory containing ChromeDriver.exe.
public ChromeDriver(string chromeDriverDirectory)
Parameters
chromeDriverDirectory
stringThe full path to the directory containing ChromeDriver.exe.
ChromeDriver(string, ChromeOptions)
Initializes a new instance of the ChromeDriver class using the specified path to the directory containing ChromeDriver.exe and options.
public ChromeDriver(string chromeDriverDirectory, ChromeOptions options)
Parameters
chromeDriverDirectory
stringThe full path to the directory containing ChromeDriver.exe.
options
ChromeOptionsThe ChromeOptions to be used with the Chrome driver.
ChromeDriver(string, ChromeOptions, TimeSpan)
Initializes a new instance of the ChromeDriver class using the specified path to the directory containing ChromeDriver.exe, options, and command timeout.
public ChromeDriver(string chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)
Parameters
chromeDriverDirectory
stringThe full path to the directory containing ChromeDriver.exe.
options
ChromeOptionsThe ChromeOptions to be used with the Chrome driver.
commandTimeout
TimeSpanThe maximum amount of time to wait for each command.
Properties
CustomCommandDefinitions
Gets a read-only dictionary of the custom WebDriver commands defined for ChromeDriver. The keys of the dictionary are the names assigned to the command; the values are the CommandInfo objects describing the command behavior.
public static IReadOnlyDictionary<string, CommandInfo> CustomCommandDefinitions { get; }