Text
2. Initialize Page Object only when you start using it
ArtifactsCreationModel artifactsCreationModel = new ArtifactsCreationModel(getDriver());
SourceFormatModel sourceFormatModel = new SourceFormatModel(getDriver());
artifactsCreationModel.getBtnSourceFormat().click(WaitMode.AJAX);
artifactsCreationModel.getBtnCreateSF().click(WaitMode.AJAX);
Assert.assertTrue(sourceFormatModel.getBtnCancelGoBack().isDisplayed());
sourceFormatModel.getTbxFormatType().clear();
3. Force developers to put element ids or unique attributes for web elements.
4. If it`s not possible to tag elements with unique locators, then don`t use DOM structure in locators
Instead of:
By.xpath("//tr/td[3]/div/div[text()='Conforming Format']"
Just use:
By.xpath("//*[text()='Conforming Format']"5. Every popup should have separate page object (model) - Popups, warnings. This makes code more 'DRY'
Incorrect approach
The right way
6. Avoid using thread sleep at all cost
Use Explicit waits instead
WebDriverWait webDriverWait = new WebDriverWait(driver, 5000);
webDriverWait.until(ExpectedConditions.visibilityOf(getLblStatus().getElement()));
OR with newer ATSF version
getLblStatus().waitForElementToBeDisplayed(5000);
7. Test classes name should end on <..Test> postfix, otherwise they are not picked up by Surefire maven plugin
8. Logging - use a logger instead of sysout
With a logger you can:
9. Better use 3rd party asserters for increasing the readability of code
Text
public ControlPeriodModel(WebDriver driver) {
super(driver);
WebDriverWait webDriverWait = new WebDriverWait(driver, 5000);
webDriverWait.until(ExpectedConditions.visibilityOf(getLblStatus().getElement()));
}
public ControlPeriodModel(WebDriver driver) {
super(driver);
this.getLblStatus().waitForElementToBeDisplayed(5000);
}
Now
Previously
ATSF in future