SteveSandersonMS / BlazorUnitTestingPrototype

94 stars 54 forks source link

idea: implement interface like Selenium ? #9

Open StefH opened 5 years ago

StefH commented 5 years ago

Maybe an idea to implement the finder logic like Selenium does.

Usage example coudl be like:

[Fact]
public void CountStartsAtZero()
{
    var component = host.AddComponent<Counter>();

    Assert.Equal("Current count: 0", component.FindVisible(By.Id("counter")).Text);
}

See https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/webdriver/By.cs

-->

//
// Summary:
//     Gets a mechanism to find elements by their CSS class.
//
// Parameters:
//   classNameToFind:
//     The CSS class to find.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
//
// Remarks:
//     If an element has many classes then this will match against each of them. For
//     example if the value is "one two onone", then the following values for the className
//     parameter will match: "one" and "two".
public static By ClassName(string classNameToFind);
//
// Summary:
//     Gets a mechanism to find elements by their cascading style sheet (CSS) selector.
//
// Parameters:
//   cssSelectorToFind:
//     The CSS selector to find.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
public static By CssSelector(string cssSelectorToFind);
//
// Summary:
//     Gets a mechanism to find elements by their ID.
//
// Parameters:
//   idToFind:
//     The ID to find.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
public static By Id(string idToFind);
//
// Summary:
//     Gets a mechanism to find elements by their link text.
//
// Parameters:
//   linkTextToFind:
//     The link text to find.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
public static By LinkText(string linkTextToFind);
//
// Summary:
//     Gets a mechanism to find elements by their name.
//
// Parameters:
//   nameToFind:
//     The name to find.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
public static By Name(string nameToFind);
//
// Summary:
//     Gets a mechanism to find elements by a partial match on their link text.
//
// Parameters:
//   partialLinkTextToFind:
//     The partial link text to find.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
public static By PartialLinkText(string partialLinkTextToFind);
//
// Summary:
//     Gets a mechanism to find elements by their tag name.
//
// Parameters:
//   tagNameToFind:
//     The tag name to find.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
public static By TagName(string tagNameToFind);
//
// Summary:
//     Gets a mechanism to find elements by an XPath query. When searching within a
//     WebElement using xpath be aware that WebDriver follows standard conventions:
//     a search prefixed with "//" will search the entire document, not just the children
//     of this current node. Use ".//" to limit your search to the children of this
//     WebElement.
//
// Parameters:
//   xpathToFind:
//     The XPath query to use.
//
// Returns:
//     A OpenQA.Selenium.By object the driver can use to find the elements.
public static By XPath(string xpathToFind);