CSSSelector Property (WebElementDescription)
The path to the object in CSS format, for example, tr.BPTRow input.

C# Syntax

public CSSDescription CSSSelector {get; set;}
// Suppose you want to verify that when entering a value in a search box, a suggestion box opens. 
// The only way to identify the suggestion box is via a CSS selector.

// The example below shows how to:
// - fire an event that triggers the opening of a suggestion box
// - identify the suggestion box using a CSS selector

public void Verify_SearchSuggestionsAreOpenUponUserInput()
    // Launch the Chrome browser and navigate to the web site.
    var browser = BrowserFactory.Launch(BrowserType.Chrome);

    // Use Try/Catch to add a warning to the run report if the assert validation fails.          
        // Enter the value "Some Text" in the search box.
        var search = browser.Describe<IEditField>(new EditFieldDescription
            Name = "q"
        search.SetValue("Some Text");

        // Simulate a single key down event to trigger the opening of the suggestion box.

        // Wait until the suggestion box opens.
        var suggestions = browser.Describe<IWebElement>(new CSSDescription(".sbsb_a"));
        suggestions.WaitUntil(suggestionsBox => suggestionsBox.Exists() && suggestionsBox.IsVisible);

        // Verify that the suggestion box exists and is visible.
        Verify.IsTrue(suggestions.Exists(), "Verify Search Suggestions UserInput Control Exists", "Verify that the suggestion box exists.");
        Verify.IsTrue(suggestions.IsVisible, "Verify Search Suggestions UserInput Control Is Visible", "Verify that the suggestion box is visible.");
    catch (Exception e)
    // Use a ReportEvent step to add details to the report if there is an error in the test.
        Reporter.ReportEvent("Verify_SearchSuggestionsAreOpenUponUserInput", "Failed during validation", Status.Failed, e);