Answer the question
In order to leave comments, you need to log in
How to properly use encapsulation in Page Object pattern?
Tell me how to properly use encapsulation in the Page Object pattern.
I read that only methods from PageObject, such as login , addToCart , etc., should be available to the client, and it's better not to use selenium methods, such as driver.click() , in tests .
But often in tests you need access to page elements, you just need to click on them, for example, or check visibility.
If you hide all page elements in a PageObject, the encapsulation becomes absurd, and you will have to write getters for each element or methods like addToCartButtonClick() .
It seems to be correct to hide elements inside PageObject and use only methods, but in practice it is very inconvenient. How to do it right?
Answer the question
In order to leave comments, you need to log in
encapsulation reaches the point of absurdity, and you have to write getters for each element or methods like addToCartButtonClick().
addToCartButtonClick
there should be a method addProductToChart
where the PageObject already decides what it needs: press the button, pull the slider, etc., then this can be called encapsulation and the absurdity will disappear. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question