Mat*_*rše 5 refactoring selenium automated-tests selenium-chromedriver selenium-webdriver
Selenium 支持类中的 LoadableComponent 和 SlowLoadableComponent 之间的具体区别是什么?
如何以及何时使用另一个?
我的理解是,您可以将两者用于需要一些时间加载的组件或元素,并且对加载含义的验证足够复杂,可以抽象为单独的方法isLoaded。不同之处在于,对于 的LoadableComponent调用get()必须给你一个完全加载的组件,否则会抛出错误,而SlowLoadableComponent可能会返回未加载的组件。
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.
| 归档时间: |
|
| 查看次数: |
271 次 |
| 最近记录: |