I like the concept of storing elements identifiers/locators outside of code, to be referenced by the page object etc. It's a design choice you can certainly make. I would consider whether you might want to use YAML as another alternative to JSON. I like YAML in that it's more compact than JSON and also supports comments.
You page object then can be all the page methods/actions only with utility method to import the locator definitions into actual objects on page instantiation if you went that route.
I like your EnterField method design. It provides abstractions to the user, but I may use something like that more as a utility method or internal private method for the framework developer. Following page object modeling and abstracted design, you want methods more like these for a page object:
SelectListItem(int index)
SelectListItem(string itemName)
SelectProductColor(string colorName)
SelectProductSize(SizeEnumType size) //where enum values SMALL, MEDIUM, LARGE, etc.
these in turn call lower level utility methods like EnterField and others to perform the appropriate action. The test writer only needs to know & think about high level aspects of the test scenario to implement w/o worrying about low level details about the actual element locators & how to work with them, only maybe just how to identify the page elements locators if need be.
But note that taking this strategy to the max benefit sometimes requires use of XPath, since CSS selectors and locating by name, ID, class, do not provide you the granularity to locate an item specifically by a particular index or text string (i.e. color name, item name, product size) anchored to some easier to find base parent element. If you forgo XPath in such cases, then you loose the ability to abstractly on higher level handle an element by specific string or index that a user normally would expect.
On Tuesday, January 19, 2021 at 10:49:38 PM UTC-8 PopVerifyPete wrote: