Skip to content

Modus-Logo-Long-BlackCreated with Sketch.

  • Services
  • Work
  • Blog
  • Resources

    OUR RESOURCES

    Innovation Podcast

    Explore transformative innovation with industry leaders.

    Guides & Playbooks

    Implement leading digital innovation with our strategic guides.

    Practical guide to building an effective AI strategy
  • Who we are

    Our story

    Learn about our values, vision, and commitment to client success.

    Open Source

    Discover how we contribute to and benefit from the global open source ecosystem.

    Careers

    Join our dynamic team and shape the future of digital transformation.

    How we built our unique culture
  • Let's talk
  • EN
  • FR

Don’t Repeat Yourself (DRY) is a software development principle that is equally important to automation software testing as it is to software development.

In testing, there are different patterns that can help you achieve this. One of them is the Page Object pattern. You’ll find that using this pattern with Sencha Test may be easier than you think.

Using the Page Object Design Pattern in Sencha Test

First of all: “Why the Page Object?”

The Page Object is a Design Pattern that offers several advantages:

  • Clean separation between test code and page specific code
  • A single place where services and operations offered by the page are placed, instead of being scattered throughout the tests

This enhances test maintenance and reduces code duplication.

To achieve the above, Page Objects have the following responsibilities:

  • Hide references to HTML element and the DOM, encapsulating the various queries performed
  • Provide higher-level operations than the exposure of elements (like filling a login form)
  • Expose frequently made assertions in public methods
  • Transitions between page objects or within the same page object, between one state to another one

Now: “How do I use the Page Object in Sencha Test?”

Sencha Test is “the most comprehensive unit and end-to-end functional testing solution for Ext JS single page apps. This cross-browser testing solution ensures that you deliver quality apps and reduce testing time. Sencha Test leverages the powerful Jasmine framework, so you can write tests in JavaScript.”

Sencha Test provides several ways of implementing the Page Object Design Pattern that we will discuss here.

Placing the Page Object inside the test:

This approach is recommended when the page object resources are used only within one test scenario.

Placing these resources within the test file may spur some discussions about whether this is an anti-pattern approach or not. Nowhere within the documentation of this pattern states that we should have different files for the page objects. What’s important is to have independent Page Object classes / objects to achieve the pattern advantages.

describe('Many tests', function () {
  var Page = {
    fooGrid: function () {
      return ST.grid('grid#foo');
    },
    nameField: function () {
      return ST.textField('textfield[name="username"]');
    }
  };
 
  it('might take some time', function () {
    Page.fooGrid().row(42).
      reveal().
      click(10, 10);
  });
 
  it('might take some more time', function () {
    Page.fooGrid().row(999).
      reveal().
      click(10, 10);
  });
});
Source: https://www.sencha.com/blog/inside-the-sencha-test-futures-api/

 

Placing the Page Object into separate files:

With this approach, you can reuse the page object resources in multiple test scenarios. To do this, you have to add it to Additional Libraries list for the test project within your project.json file as in the example below:

"libs": [
  {
    "disabled": false,
    "path": "/e2e/pages/common/page3.po.js"
  },
  {
    "disabled": false,
    "path": "/e2e/pages/common/page4.po.js"
  }
],

“libs” is a root project property that can also contain any other utility / component classes needed within the test project. All objects added to Additional Libraries are global test objects.

Defining the page object:

var Page = {
  fooGrid: function () {
    return ST.grid('grid#foo');
  },
  nameField: function () {
    return ST.textField('textfield[name="username"]');
  }
};

Using the page object:

describe('Many tests', function () {
 
  it('might take some time', function () {
    Page.fooGrid().row(42).
      reveal().
      click(10, 10);
  });
 
  it('might take some more time', function () {
    Page.fooGrid().row(999).
      reveal().
      click(10, 10);
  });
});

This may be confusing and we may expect to see an Object not defined error when calling Page but that is not the case. Since all objects added to Additional Libraries are global test objects, the above will work as expected.

Conclusion

The Page Objects pattern helps you develop faster, easier and cleaner tests. Maintenance is also easy since OOP principles are applied.

Using this test development pattern with Sencha Test can be as easy as with other test frameworks like Protractor.

Example code can be found here.

Posted in Application Development, Quality Assurance
Share this

Sergiu Popescu

Sergiu Popescu is a QA Engineer at Modus Create. He specializes in automating test processes for web and hybrid apps using Java, JS, and a wide range of tools and libraries like TestNG, jUnit, Webdriver, WebdriverJS, Protractor and Siesta. When he is not hunting bugs in apps, he enjoys spending time with his lovely wife and son.

Related Posts

  • Screenplay Test Design Pattern
    The Screenplay Test Design Pattern

    The Screenplay Test Design Pattern, also known as the Flow Pattern, has been around since…

  • Screenplay Test Design Pattern
    The Screenplay Test Design Pattern

    The Screenplay Test Design Pattern, also known as the Flow Pattern, has been around since…

Want more insights to fuel your innovation efforts?

Sign up to receive our monthly newsletter and exclusive content about digital transformation and product development.

What we do

Our services
AI and data
Product development
Design and UX
IT modernization
Platform and MLOps
Developer experience
Security

Our partners
Atlassian
AWS
GitHub
Other partners

Who we are

Our story
Careers
Open source

Our work

Our case studies

Our resources

Blog
Innovation podcast
Guides & playbooks

Connect with us

Get monthly insights on AI adoption

© 2025 Modus Create, LLC

Privacy PolicySitemap
Scroll To Top
  • Services
  • Work
  • Blog
  • Resources
    • Innovation Podcast
    • Guides & Playbooks
  • Who we are
    • Careers
  • Let’s talk
  • EN
  • FR