What is the specific difference between LoadableComponent and SlowLoadableComponent in Selenium support classes?
How and when to use one over the other?
What is the specific difference between LoadableComponent and SlowLoadableComponent in Selenium support classes?
How and when to use one over the other?
My understanding is you would use both for components or elements that take some time to load, and the verification of what it means to be loaded is complex enough to be abstracted to a separate method isLoaded. The difference is that for LoadableComponent the call to get() must give you a fully loaded component, or throw an error, while SlowLoadableComponent may be returned unloaded.
That said, LoadableComponent would be used for elements you are only interested in once they are fully loaded and ready to use. You don't mind waiting for them to fully load and have no case to interact with them in their intermediate state. And if they fail to load - that means test over. Main use case I'd imagine is simply hiding the logic behind page loading and waiting for it.
SlowLoadableComponent on the other hand can be returned from its get method before it loads fully, giving you control over things like putting assertions on its load time in test (instead of hardcoding them in the component) or having a chance to interact with other elements that may affect the component loading. I can imagine a testcase relying on SlowLoadableComponent never being fully loaded under certain circumstances (e.g. checkbox not ticked) which is NOT a cause for execution failure.
The SlowLoadableComponent is a subclass of the LoadableComponent but does not have to finish loading when load() returns. After a call to load(), the isLoaded() method will be failing until the component fully loads.
You use SlowLoadableComponent, if you do not need to call get() method immediately (because it needs it to be fully loaded) and you want to continue to perform some other actions first. But as soon as you need to perform get(), you should apply isLoaded() to be sure you can proceed with your code.
Overall, SlowLoadableComponent can speed up execution of your code, if you need get() at later stage or might not need it at all.