UI Automation performance and the Page Object pattern

In one of my previous posts I provided an example which turned out to be of disadvantage:

function LoginView() {
    this.loginCells = window.tableViews()[0].cells();
    this.loginField = this.loginCells["loginFieldCell"].textFields()["loginField"];
    this.passwordField= this.loginCells["passwordFieldCell"].secureTextFields()["passwordField"];
    this.loginButton = this.loginCells["loginButtonCell"].buttons()["loginButton"];

Caching element paths in the constructor takes too much time, if:
  • Element variables refer to already cached subelements
  • The view currently isn't displayed.
This issue can be resolved as follows:

function LoginView() {

LoginView.prototype.login = function(user, password) {

Via this approach I don't put a runtime dependency on the creation of the LoginView object, so I can reuse anytime and anywhere in my test.
Although I use direct access in the UI Automation element tree due to the application of the Page Object pattern it doesn't disturb me, nor did I have to change anything in the test cases.

No comments:

Post a Comment