First of all, the first trip-over is the isLoaded() HAS TO be implemented. If you leave it blank, your LoadableComponent will not be loaded. There is no error or any warning. You JUnit test will just keep hanging there and waiting until timeout.
Second thing, which is still a myth to me, is if the isLoaded() method is called to access some elements are not ready on the page yet (which is logical and common and even from the official example provided on Selenium Wiki), it does not ALWAYS successful. It seems we have to force the load() method to be called (to load the element) before any isLoaded() validation kicks in.
With debugging, I found the isLoaded() method is actually called before load() method and then is called again. It sort of makes me feeling confused as with example on Selenium Wiki, it looks logical that load() method is the first method will be called upon calling the get() method of the LoadableComponent but it is not (the load() and isLoaded() methods are not exposed to use publicly anyway and we do not have any other choices).
However, my expectation on how to use these two methods are completely flipped after I found this post on the Internet, then it explained why I have been experiencing the problems above as the load() method will not be called at first and only isLoaded() method is called and then if it is not successful, it will then call load() method. However, in my case, some of my tests on isLoaded() calls are still not successful for some (unknown) reason(s) and that is still a myth.
So the official guide of using LoadableComponent is not quite correct and it sort of leads us to think the load() method is the place we put all the logic to load the page whereas isLoaded() method is the place we put the validation on checking whether the page is loaded or not. So to my impression, load() method should be the one we always implement as it is the access point of the page and will be called first. However, from the source code in that post, it seems load() method is not necessarily to be implemented whereas the isLoaded() method is one has to be implemented.
Moreover, my pages are loadable components and in dependency on other pages. So the load() method cannot be placed in the Contructor. At the end, my solution is to call my load() method as the first line in my isLoaded() method. This then solved my problems. However, I still do not think it is nice.
No comments:
Post a Comment