Add Methods
hvstr provides an interface, to add useful methods to a page-object.
AddNavigateTo
call the
addNavigateTo
on a
IPageObjectInFabrication to add the navigateTo
method.
Example:
let homePage = await pageObjectBuilder.generate({
name: 'HomePage',
byRoute: '/home',
});
homePage = await homePage.addNavigateTo();
the generated Page-object will now have a navigate Method and a route property.:
export class HomePage {
route = '/home';
navigateTo = () => browser.get(this.route);
}
Note: The route property is determined by the browsers current route, not from the byRoute
parameter.
AddFillForm
call the
addFillForm
on a
IPageObjectInFabrication to add the fillForm
method.
The fillForm
method helps you to fill up large forms. It expects an object as parameter, which has a property for each input, to determine the values, which should be send to the input.
addFillForm
also adds a clearForm
method, to remove the content from all these inputs.
Example:
let homePage = await pageObjectBuilder.generate({
name: 'HomePage',
byRoute: '/home',
});
homePage = await homePage.addFillForm();
the generated Page-object will now have a navigate Method and a route property.:
export class HomePage {
route = '/home';
navigateTo = () => browser.get(this.route);
}