You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website_and_docs/content/documentation/test_practices/encouraged/page_object_models.en.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,13 +198,15 @@ requests from the test.
198
198
199
199
## Page Component Objects
200
200
A page object does not necessarily need to represent all the parts of a
201
-
page itself. The same principles used for page objects can be used to
202
-
create "Page _Component_ Objects" that represent discrete chunks of the
201
+
page itself. This was [noted by Martin Fowler](https://martinfowler.com/bliki/PageObject.html#footnote-panel-object) in the early days, while first coining the term "panel objects".
202
+
203
+
The same principles used for page objects can be used to
204
+
create "Page _Component_ Objects", as it was later called, that represent discrete chunks of the
203
205
page and can be included in page objects. These component objects can
204
206
provide references to the elements inside those discrete chunks, and
205
207
methods to leverage the functionality provided by them.
206
208
207
-
For example, a Product page has multiple products.
209
+
For example, a Products page has multiple products.
208
210
209
211
```html
210
212
<!-- Products Page -->
@@ -242,7 +244,7 @@ Each product is a component of the Products page.
242
244
</div>
243
245
```
244
246
245
-
The Product page HAS-A list of products. This relationship is called Composition. In simpler terms, something is _composed of_ another thing.
247
+
The Products page HAS-A list of products. This object relationship is called Composition. In simpler terms, something is _composed of_ another thing.
246
248
247
249
```java
248
250
publicabstractclassBasePage {
@@ -325,7 +327,7 @@ So now, the products test would use the page object and the page component objec
325
327
publicclassProductsTest {
326
328
@Test
327
329
publicvoidtestProductInventory() {
328
-
var productsPage =newProductsPage(driver);
330
+
var productsPage =newProductsPage(driver);// page object
329
331
var products = productsPage.getProducts();
330
332
assertEquals(6, products.size()); // expected, actual
331
333
}
@@ -336,7 +338,7 @@ public class ProductsTest {
336
338
337
339
// Pass a lambda expression (predicate) to filter the list of products
338
340
// The predicate or "strategy" is the behavior passed as parameter
339
-
var backpack = productsPage.getProduct(p -> p.getName().equals("Backpack"));
341
+
var backpack = productsPage.getProduct(p -> p.getName().equals("Backpack"));// page component object
340
342
var bikeLight = productsPage.getProduct(p -> p.getName().equals("Bike Light"));
0 commit comments