Class ChromeDriver
Provides a mechanism to write tests against Chrome
public class ChromeDriver : RemoteWebDriver, IWebDriver, IDisposable, ISearchContext, IJavaScriptExecutor, IFindsById, IFindsByClassName, IFindsByLinkText, IFindsByName, IFindsByTagName, IFindsByXPath, IFindsByPartialLinkText, IFindsByCssSelector, ITakesScreenshot, IHasInputDevices, IHasCapabilities, IAllowsFileDetection
- Inheritance
-
ChromeDriver
- Implements
- Inherited Members
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
serviceChromeDriverServiceThe 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
serviceChromeDriverServiceThe ChromeDriverService to use.
optionsChromeOptionsThe 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
serviceChromeDriverServiceThe ChromeDriverService to use.
optionsChromeOptionsThe ChromeOptions to be used with the Chrome driver.
commandTimeoutTimeSpanThe 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
optionsChromeOptionsThe 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
chromeDriverDirectorystringThe 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
chromeDriverDirectorystringThe full path to the directory containing ChromeDriver.exe.
optionsChromeOptionsThe 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
chromeDriverDirectorystringThe full path to the directory containing ChromeDriver.exe.
optionsChromeOptionsThe ChromeOptions to be used with the Chrome driver.
commandTimeoutTimeSpanThe maximum amount of time to wait for each command.
Fields
AcceptUntrustedCertificates
Accept untrusted SSL Certificates
public static readonly bool AcceptUntrustedCertificates
Field Value
Properties
FileDetector
Gets or sets the IFileDetector responsible for detecting sequences of keystrokes representing file paths and names.
public override IFileDetector FileDetector { get; set; }
Property Value
Remarks
The Chrome driver does not allow a file detector to be set, as the server component of the Chrome driver (ChromeDriver.exe) only allows uploads from the local computer environment. Attempting to set this property has no effect, but does not throw an exception. If you are attempting to run the Chrome driver remotely, use RemoteWebDriver in conjunction with a standalone WebDriver server.