-
Notifications
You must be signed in to change notification settings - Fork 31
Block
vefimofff edited this page Nov 21, 2017
·
6 revisions
Block class basically represents some area of a browser page. It contains all possible actions and checks that a user can do inside this area. Block area is limited by the main element of a block.
All block classes should extend AbstractBlock class.
To create a block a TeasyElement should be passed to its constructor from a Page.
class SomePage extends AbstractPage {
public SomeBlock getSomeBlock() {
return new SomeBlock(element(By.id("mainElementForSomeBlock")));
}
}
class SomeBlock extends AbstractBlock {
public SomeBlock(TeasyElement el) {
super(el);
}
}
All methods that provide elements (element(), elements(), domElement()
, etc.) will automatically search only within main element of a block.
And don't let your Block grow into a monster. 300 LoC is a reasonable limit for a good block.