IntelliTect / TestTools

A collection of tools for aiding in test automation
MIT License
10 stars 7 forks source link

Convert ElementHandler methods to delegates #69

Closed PandaMagnus closed 3 years ago

PandaMagnus commented 4 years ago

Currently we take in an IWebElement. Originally I thought this would suffice since, if we use Browser to find said element, we get a wait on the find, and then the wait for an action in the ElementHandler class.

This ends up producing some unexpected results sometimes (if the element isn't found, Browser.FindElement is the thing that throws despite a test explicitly invoking ElementHandler.) This should be changed to accept a delegate so that the evaluation does not occur until inside the ElementHandler wait. Some considerations:

1) In cases where we call ElementHandler, we may need to circumvent the wait in Browser.FindElement (if we're finding the element using Browser.FindElement). Nested waits get hairy and we probably want to avoid having the Browser.FindElement wait inside of ElementHandler waits. 2) We don't want to remove the existing methods yet. We should obsolete them to maintain support for the next... period of time/number of versions (obsolete might not be the right thing to do yet. Maybe leave them as-is and deprecate after the new methods have been available for a few months.) 3) This could have broader implications on Browser.FindElement. It may no longer be appropriate to have a wait under the covers here, unless we rename this to be super clear what it's doing.

PandaMagnus commented 4 years ago

ALSO NOTE: Found an odd edge condition. If/when this happens, change "SendKeysWhenReady" to something like "SendTextWhenReady". Keys.* actions don't work with this method.

PandaMagnus commented 4 years ago

Testing out a potentially more straightforward option: turn ElementHandler method arguments to taking in Bys instead of IWebElements or delegates.

As part of this, we could deprecate Browser.FindElement, or maybe leave it as a "if you want to," option. This would likely comprise v2, which I'm hoping to knock out an alpha version of this weekend.

PandaMagnus commented 3 years ago

Been using an alternate-alternate approach where IWebElements are wrapped very similarly to how Browser wrapped IWebDriver. Unified semantics to DriverHandler, ElementHandler, and ElementsHandler. It's been working extremely consistently at a client site. Probably ready for some finishing touches, adding unit tests (see #101 ) and a beta version that deprecates the existing v1 functionality.

PandaMagnus commented 3 years ago

Still working consistently. I think the only thing I want to look into before putting in a PR to merge to main is ways to make this easily swappable back to vanilla Selenium should the need arise (I think currently a few key find and replace alls should do the trick, but I want to verify.)

PandaMagnus commented 3 years ago

Exposed methods that allow using vanilla Selenium if needed when the Selenate waits aren't enough. This has been working well. Closing this issue.