2

What is the difference between using WebDriverFacade as opposed to Page Objects. I searched a lot and just can't seem to understand or find the answers. I am declaring WebDriverFacade for all my elements and do get the added functionality of waits, etc added before action happens on the element, which is good, but then what does Page object do differently other than getdriver()? Which one should I be using?

2
  • Page Object is a design approach while WebDriverFacade is a library which implements a webdriver wrapper. – PDHide May 2 at 6:45
  • Please add more information – PDHide May 2 at 6:46
4

They are two different design patterns.

A Facade is meant to make the interface to a library or set of objects simpler. It wraps in simpler methods complex behavior or "outdated" style of programming, thus making the overall style of your project cleaner, even if you have to rely on some nasty ugly dependencies.

enter image description here

It does not have anything to do with your business logic.

A Page Object on the other hand is connected to your business logic. It will implement ways of interacting with a UI element, exposing behavior-like methods such as completeOrder and performLogin.

enter image description here

Most probably you will use both the WebDriverFacade and Page Objects, injecting the former into the latter, so that you will be able to implement the behavior methods.

class HomePage {
  
   HomePage(WebDriverFacade driver)() { this.driver = driver; }
   fun doStuff() { driver.getElement(blablabla).click(); }

}
6
  • I don't think I am still clear about the difference. Also if I am using WebDriverFacade can I use WebDriverListener to log events? If yes how? – Suhas May 6 at 5:27
  • The main difference is that a Facade is a gateway for more complex object interaction. In the context we are, it doesn't describe the SUT, but helps to deal with a more complex API (In this case, the WebDriver API). A Page Object describes your SUT, it has business logic, not acting simply as a gateway to other objects. – João Farias May 6 at 7:18
  • WebDriverListener would be a different question. I suggest reading this article seleniumeasy.com/selenium-tutorials/… In here you can see how you register a WebDriverListener in an EventFiringWebDriver. – João Farias May 6 at 7:18
  • Thank you for your response João. – Suhas May 6 at 16:09
  • Regarding webdriverListener I know how to use it while just using selenium but am not sure how to use it in the context of webdriverfacade – Suhas May 6 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.