Table of Contents

Class SafariDriver

Namespace
OpenQA.Selenium.Safari
Assembly
WebDriver.dll

Provides a way to access Safari to run your tests by creating a SafariDriver instance

public class SafariDriver : WebDriver, IWebDriver, IDisposable, ISearchContext, IJavaScriptExecutor, IFindsElement, ITakesScreenshot, ISupportsPrint, IActionExecutor, IAllowsFileDetection, IHasCapabilities, IHasCommandExecutor, IHasSessionId, ICustomDriverCommandExecutor, IHasVirtualAuthenticator
Inheritance
SafariDriver
Implements
Inherited Members
Extension Methods

Examples

[TestFixture]
public class Testing
{
    private IWebDriver driver;

    [SetUp]
    public void SetUp()
    {
        driver = new SafariDriver();
    }

    [Test]
    public void TestGoogle()
    {
        driver.Navigate().GoToUrl("http://www.google.co.uk");
        /*
        *   Rest of the test
        */
    }

    [TearDown]
    public void TearDown()
    {
        driver.Quit();
        driver.Dispose();
    }
}

Remarks

When the WebDriver object has been instantiated the browser will load. The test can then navigate to the URL under test and start your test.

Constructors

SafariDriver()

Initializes a new instance of the SafariDriver class.

public SafariDriver()

SafariDriver(SafariDriverService)

Initializes a new instance of the SafariDriver class using the specified driver service.

public SafariDriver(SafariDriverService service)

Parameters

service SafariDriverService

The SafariDriverService used to initialize the driver.

SafariDriver(SafariDriverService, SafariOptions)

Initializes a new instance of the SafariDriver class using the specified SafariDriverService and options.

public SafariDriver(SafariDriverService service, SafariOptions options)

Parameters

service SafariDriverService

The SafariDriverService to use.

options SafariOptions

The SafariOptions used to initialize the driver.

SafariDriver(SafariDriverService, SafariOptions, TimeSpan)

Initializes a new instance of the SafariDriver class using the specified SafariDriverService.

public SafariDriver(SafariDriverService service, SafariOptions options, TimeSpan commandTimeout)

Parameters

service SafariDriverService

The SafariDriverService to use.

options SafariOptions

The SafariOptions to be used with the Safari driver.

commandTimeout TimeSpan

The maximum amount of time to wait for each command.

SafariDriver(SafariOptions)

Initializes a new instance of the SafariDriver class using the specified SafariOptions.

public SafariDriver(SafariOptions options)

Parameters

options SafariOptions

The SafariOptions to use for this SafariDriver instance.

SafariDriver(string)

Initializes a new instance of the SafariDriver class using the specified path to the directory containing safaridriver.

public SafariDriver(string safariDriverDirectory)

Parameters

safariDriverDirectory string

The full path to the directory containing SafariDriver executable.

SafariDriver(string, SafariOptions)

Initializes a new instance of the SafariDriver class using the specified path to the directory containing safaridriver and options.

public SafariDriver(string safariDriverDirectory, SafariOptions options)

Parameters

safariDriverDirectory string

The full path to the directory containing SafariDriver executable.

options SafariOptions

The SafariOptions to be used with the Safari driver.

SafariDriver(string, SafariOptions, TimeSpan)

Initializes a new instance of the SafariDriver class using the specified path to the directory containing safaridriver, options, and command timeout.

public SafariDriver(string safariDriverDirectory, SafariOptions options, TimeSpan commandTimeout)

Parameters

safariDriverDirectory string

The full path to the directory containing SafariDriver executable.

options SafariOptions

The SafariOptions to be used with the Safari driver.

commandTimeout TimeSpan

The maximum amount of time to wait for each command.

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

IFileDetector

Remarks

The Safari driver does not allow a file detector to be set, as the server component of the Safari driver (the Safari extension) 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 Safari driver remotely, use RemoteWebDriver in conjunction with a standalone WebDriver server.

Methods

AttachDebugger()

This opens Safari's Web Inspector. If driver subsequently executes script of "debugger;" the execution will pause, no additional commands will be processed, and the code will time out.

public void AttachDebugger()

GetPermissions()

Returns Each available permission item and whether it is allowed or not.

public object GetPermissions()

Returns

object

whether the item is allowed or not.

SetPermission(string, bool)

Set permission of an item on the browser. The only supported permission at this time is "getUserMedia".

public void SetPermission(string permissionName, bool permissionValue)

Parameters

permissionName string

The name of the item to set permission on.

permissionValue bool

Whether the permission has been granted.