Add Custom WebDriver Capabilities

Learn how to add custom WebDriver capabilities.

Example

[TestFixture]
[App(Constants.WpfAppPath, Lifecycle.RestartEveryTime)]
public class AddCustomWebDriverCapabilitiesTests : DesktopTest
{
    public override void TestsArrange()
    {
        App.AddAdditionalCapability("appArguments", @"MyTestFile.txt");
        App.AddAdditionalCapability("appWorkingDir", @"C:\MyTestFolder\");
    }

    [Test]
    public void MessageChanged_When_ButtonHovered_Wpf()
    {
        var button = App.Components.CreateByName<Button>("E Button");

        button.Hover();

        var label = App.Components.CreateByName<Button>("ebuttonHovered");
        Assert.AreEqual("ebuttonHovered", label.InnerText);
    }

    [Test]
    [App(Constants.WpfAppPath, Lifecycle.RestartOnFail)]
    public void MessageChanged_When_ButtonClicked_Wpf()
    {
        var button = App.Components.CreateByName<Button>("E Button");

        button.Click();

        var label = App.Components.CreateByName<Button>("ebuttonClicked");
        Assert.AreEqual("ebuttonClicked", label.InnerText);
    }
}

Explanations

App.AddAdditionalCapability("appArguments", @"MyTestFile.txt");
App.AddAdditionalCapability("appWorkingDir", @"C:\MyTestFolder\");

BELLATRIX hides the complexity of initialisation of WebDriver and all related services. In some cases, you need to customise the set up of the app with adding driver capabilities. Using the App service methods you can add all of these with ease. Make sure to call them in the TestsArrange which is called before the execution of the tests placed in the test class. These options are used only for the tests in this particular class.