Modern Automation Frameworks

1) Keyword Driven : Keywords are essentially blocks or functions that are named so that they can be consumed for a given functionality. At a simplest level, keyword takes in parameters and throws back some output. Keywords are written to abstract the complexity of repeatedly writing code. Think of Keywords as API’s that serve you (or your application) when called. In one of the frameworks I designed for a large company, Keywords.java was a Class file with list of Java methods with defined inputs and outputs. There is a very thin line between keywords and modules. We hear the term “modularization” or “modular framework” and so on and there is a intersection of spaces here.

关键字驱动

2) Data Driven: If your applications is NOT too deep with pages , however each page can have scenarios that need to be tested with large datasets, you would want to write automation scripts with a focus on test data aka. data-driven. Tools like QTP already have excel sheet parsing etc that loops through rows and the same test case is executed for each data-set. It helps me to think in an easier way when I talk about excel for data driven, however please DO NOT think excel is the most optimum way to handle test data. In fact, excel is heavier than xml, yml or other data exchange formats. If you are at the beginning of designing a data-driven framework, go ahead and use a spreadsheet to manage your data, however as you mature and advance, try doing away with spreadsheets.

数据驱动

3) Page Object: This is a very popular pattern used these days for Test Automation Frameworks. If you think of a web based application as a network of pages that interact with each other AND there are large number of pages in your application that can change nature frequently, this pattern is the most favorable one to use.

 页面对象

Page-objects (or classes) are defined for each page, where a page contains the html locator information and also the methods that can operate on those page elements. Though we say page-objects (aka. classes) are written for each page, there are some nuances in terms of how we model a Web page into a page-object. A network of page-objects is supposed to model the state of the web application ultimately, however with asynchronous web applications, where parts of page get refreshed (as opposed to full web page. aka. DOM), we have to handle ajax calls based on the javascript library. Anyways, will mention the caveats, pros and cons, situations in which web application (page html source) to page-object modeling becomes the most important piecein your framework etc, will be dealt in a separate post at the end of frameworks tutorial.The advantage of this pattern from the decision making point is:

 
  • If a html locator information changes for an element, changing it in the page-object reflects across all the scripts – nice right
  • Gives us ability to define keywords too as we can define methods inside page-objects
  • We can define navigation logic between the pages too as a way to tie the links between the pages
 

4) Hybrid: A Hybrid model is permutations and combinations of the above three frameworks described

混合模式

posted @ 2018-01-03 17:08  thisissweetcandy  阅读(56)  评论(0)    收藏  举报