What is the standard approach when applying the PageObjects template to page components?
For example, let's say that I write tests for functions on the Amazon product page.
This page contains a large number of individual functions, product information, customers who have considered this, other customers offered, etc. etc.
The current examples I've seen for PageObjects really only cover how to work with one page with limited functionality. What I'm looking for is something like a PageObject line that will represent the Product page, and then consists of ComponentObjects that represent each component.
eg:
public class ProductPage { [FindsBy(How = How.Id, Using = "productInformation")] public ProductInformationControl ProductionInformation{get;set} [FindsBy(How = How.Id, Using = "customersViewed")] public CustomersAlsoViewedControl CustomersAlsoViewed{get;set} [FindsBy(How = How.Id, Using = "customersSuggested")] public CustomersSuggestedControl CustomersSuggested{get;set} } public class ProductInformationControl {
Then, as part of the test, I would gain access to the control as follows:
var productPage = ScenarioContext.Current.Get<ProductPage>(); Assert.That(productPage.ProductInformation.GetTitle(), Is.EqualTo("My Title"));
I used this approach earlier, but with a custom structure built on top of Selenium, which allowed resolving child objects and their components. What I'm looking for is an approach that you can take with Selenium 2 and C # out of the box.
source share