Closed
Description
Feature and motivation
This is a continuation of #14530 point 1: "Discriminated unions". I proposed and implemented Local.Css
nested type instead of CssLocator
type. My last comment in that already resolved issue was:
I feel
new CssLocator("div");
is better, we can make it before v5 if we have strong arguments (types discovery is a good argument).
I was wrong, and now I come with arguments. Actually only one argument. Nested type reserves its name in the parent. Which means we cannot add more members with the same name.
Use cases:
- Static factory: when Selenium Team will have capacity to add more useful methods like
Locator.Css("div")
it will not be possible, becauseCss
is already defined inLocator
class. - Static singleton: In
Script
module we haveLocalValue.Null
class. This is great candidate to be singleton. But we cannot do it becauseNull
name is already reserved by nested type.
Usage example
Before:
new Locator.Css("div");
After:
new CssLocator("div");
And all types with similar pattern.