Granular Keyword Driven Testing

Granular Keyword Driven Testing

Keyword driven testing is a test automation approach where a tester designs his/her automated test using pre-coded keywords. When I take a quick look at the samples in web, I see that the keywords are supposed to be high level such as login, send email, check account balance etc.

What we are using in our company is what I can call as Granular Keyword Driven Testing. In this approach, keywords are designed to be more granular. So instead of a keyword like login, we use keywords like set test, click button etc.

Moreover, our keywords accept a user control’s visible property or label. For instance, if there is a textbox labeled “User”, our set text keyword accepts its label, such as set text(“User”, “John”).

So instead of implementing a single black-box keyword named “login”, we implement “set text” and “click button” keywords. Then the tester uses these granular keywords to implement his/her white box login method:

Keyword             Parameters
-----------         ---------------

Set text            User, John
Set text            Password, MyPasword123
Click button        Login
Check text          Hi John

The tester then uses this login method in his other keyword driven tests to implement other tests:

Keyword             Parameters
-----------         ---------------

Login               John, MyPassword123
Click button        Money Transfer
Set text            Amount, 1000
Set text            Receiver IBAN, TR032468706
Click button        Send
Check text          Money sent

These Granular Keywords should be implemented in such a way that they should be able to predict a user control’s XPATH from a given label. So the keyword set text can be implemented as (using a pseudo-code):

Keyword set_text(string label, string text)

{
   Var xpath = "https://*[@text='"+label+"']/..//input"//any input that is under the same parent with the given label object

   Var textbox = findElementByXpath(xpath);

   Textbox.setText(text);
}

 One question can be what to do with objects that have no label or hint. A simple if added to the code above solves this:

Keyword set_text(string label, string text)

{
   Var xpath = label;   //assuming xpath is specified in the label parameter

   if (!xpath.startsWith("https://"))
      xpath = "https://*[@text='"+label+"']/..//input"//any input that is under the same parent with the given label object

   Var textbox = findElementByXpath(xpath);

   Textbox.setText(text);
}

So the tester will be able to specify the actual xpath if the object has no visible label (or it is actually an image).

This simple approach can be used for granular keywords such as click button, check text etc.

An Alternative to Page Object Model?

Page Object model is used to define objects for elements on a page so that they can be managed from a single point in code. I'm sure it has better meanings and usages but lets keep it simple for now :D

Granular keywords seem to eliminate the need for Page Object approach. Granular keywords can be used on any page that uses the same relation (or hierarchy) between an object and its label. This is generally what happens in most of the applications: The same object hierarchy (a DIV containing both the label and the textbox for instance) is used in most of the pages.

If there is a specific object which does not comply with the general hierarchy, there are 2 options:

  1. Use its xpath, if this case is rare.
  2. Write a new keyword, if this case is seen often (a new application or a different section of it).

To summarize, we've been using granular keywords in our company for mobile, web and desktop applications; without writing any page object. And we have hundreds of automation scripts, which are more readable and maintainable (GUI changes in labels are detected and corrected easily by testers).

Please comment to make this post better :)

要查看或添加评论,请登录

?a??n Uludamar的更多文章

  • Son DevNot ve Tekerle?in yeniden icad?

    Son DevNot ve Tekerle?in yeniden icad?

    üst y?netim ?zeti :) Tekerle?i yeniden icat etmeye karar verdiyseniz ne i?e yarad???n? ve ?zelliklerinin ??k??…

    2 条评论
  • Enjoy the process, not the result

    Enjoy the process, not the result

    Today I caught myself saying this to my daughter: She was focused on finishing her next toy ATM, trying to glue the…

  • Life is a test!

    Life is a test!

    Today's entrepreneurs are looking for ways to test new ideas as fast as possible. This means that the implementation of…

  • The Myth About Test Automation

    The Myth About Test Automation

    Test automation professionals can count benefits or aims of test automation as: Save time and money Increase test…

    2 条评论
  • ?? Yeri Kokusu ve Anketi

    ?? Yeri Kokusu ve Anketi

    Scrum Master'lar olarak yapt???m?z okuma etkinliklerinden birinde i? yeri kokusu konulu bir video izlemi?tik. K?sa…

    1 条评论
  • AI and Test Automation

    AI and Test Automation

    I see lots of different articles, solutions etc about artificial intelligence which makes me think about the future of…

  • Test otomasyonunun insani boyutu

    Test otomasyonunun insani boyutu

    Yapt???n?z i? ne olursa olsun, i?inizin insani boyutunu g?rdü?ünüz zaman ona bak???n?z da büyük oranda de?i?iyor…

    3 条评论
  • Object Map Kullanmadan ?nyüz Otomasyonu

    Object Map Kullanmadan ?nyüz Otomasyonu

    Granüler Kelime Güdümlü Test makalemden ald???m bir geri d?nü?, bu y?ntemin potansiyeli ile ilgili yeterince ilgi…

  • Granüler Kelime Güdümlü Testler

    Granüler Kelime Güdümlü Testler

    Kelime Güdümlü Test (?ngilizce Keyword Driven Testing veya k?saca KDT), basit anahtar kelimeler kullanarak test…

  • A Test Automation Architecture Proposal for Big Organizations

    A Test Automation Architecture Proposal for Big Organizations

    In big organizations where there are lots of different applications to automate, test automation should be coordinated…

社区洞察

其他会员也浏览了