PageObjects
"Page objects are a classic example of encapsulation - they hide the details of the UI structure and widgetry from other components (the tests)." (c) Martin Fowler, PageObject.
So it's all about how you encapsulate "tech details". Here are just a few examples to compare.
No Encapsulation
public class GoogleTest {
@BeforeClass
public static void setup() {
Configuration.baseUrl = "http://google.com/ncr"
}
@Test
public void userCanSearch() {
open("/");
$(By.name("q")).val("selenide").pressEnter();
$$(".srg .g").shouldHave(size(10));
$$(".srg .g").get(0).shouldHave(text("Selenide: concise UI tests in Java"));
}
}Mid-level encapsulation
where:
Higher level encapsulation
where:
More examples
More examples and variations of this pattern can be found in the following talks:
Last updated
Was this helpful?