ATSF do's, dont`s and future

 

Summary

  • What can be improved 
  • ATSF latest versions` features
  • Upcoming  ATSF features (IN PROGRESS)
  1. Adding explicit wait while initializing Page Object

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:

  • easily change log levels
  • turn it off
  • customize it

9. Better use 3rd party asserters for increasing the readability of code

  • Hamcrest
  • AssertJ
  • etc

New ATSF framework features

  • Each page object method should return itself - fluent approach
  • Each page object should be extended from Model. Model is like a helper with additional explicit waits and other goodies
    •     Hence, while creating own page objects, parent constructor should be called providing webdriver instance as a parameter

Text

Useful methods

  • isDisplayed
  • isEnabled
  • isExists
  • waitForPageUpdate
  • waitForElementElementInvisibility
  • waitForElementToBeClickable
  • waitProgressBarIsHidden
  • waitForElementToBeDisplayed
  • click
  • actionClick
  • mouseOver
  • getAttribute
  • sendKey
  • getElement
  • pause
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

  • PageFactory
  • Better Selenium Grid management

ATSF do's, don'ts and future

By Ilja Pavlovs

ATSF do's, don'ts and future

  • 213