How can I structure Selenium tests in a way that minimizes the maintenance work?

  • What is the best way to build/structure the tests in a way that will minimize the work needed to keep the tests up to date as the product changes and improves?

  • As others said, use Pageobject and other best practices. Few links:


    • Use PageObjects pattern
    • Be fluent with
      • return this, varargs, generics,
      • reuse your model and jodatime
    • Be robust and portable
      • Prefered selector order : id > name > css > xpath
      • Avoid Thread.sleep prefer Wait or FluentWait
      • Use relative URLs
      • Don’t rely on specific Driver implementation
      • Create your dataset
    • Know your new tool
      • Keep up to date (versions and usage pattern)
      • Troubleshooting
        • jre 1.6
        • IE (zoom, Protected mode setting )
        • Firefox/firebug startpage
      • How to deal with UI components like... fileupload, datepicker, ajaxtables,...
      • Detect when selenium isn't a good tool for the job
      • Don't be afraid to hack around selenium

    Googling "pageobject" and "best practices" will give you many more links for your system and language.

    PageObject encapsulates a bunch of page interactions and locators for them, so the test can call a pageobject method to perform some action on a page without knowing about HTML, locators etc.

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2