Wednesday, 6 January 2016

Basic Structure Of Senuji Test Script

 

Introduction

As I explained before Senuji is a Keyword driven wraps around Selenium. Senuji has set of Keywords witch calls Selenium functionality and execute during run time. For this Senuji Keyword needs two main components.
  1. Value attribute witch carry parameters to actual selenium run time.
  2. Locator/Object attribute witch carry the HTML object information to actual selenium run time.
Senuji has stranded syntax to manage above attributes. Evey Senuji Keyword looks like following
KeyWordName[Space]"Value attribute"[Space]"Locator/Object attribute".

My First Senuji Test Script


For example, Assume we want to Google.lk web site in Fire Fox Browser. Then I need to create a Project and  Test Script as per my previous post How to create Senuji project and run.

Then I need to go to Keyword List and select Open Keyword and Enter Google.lk URL into Value TextBox. Please refer to below screen shots

 

Now Click Add New Line Button. Then Senuji Keyword will be automaticaly compute and Keyword will be added as a script line to active script.




Now for example say you want to wait until Gmail Link appear in the browser. For this I am going to use Senuji Keyword WaitForElementPresent. WaitForElementPresent requires Object/Locator of the Gmail Link. I use Fire Path object spy to understand the object and enter it to Senuji Object TextBox.




 Fire path object spy helped me to identify Locator for Gmail link. It class="gb_P". Now I am going to select WaitForElementPresent from Keyword List and select Class Name as Locator type from Locator type combo box and locator ID "gb_P" in to object textbox. However
WaitForElementPresent dose not require value parameter so I am keeping it as blank.





Now I click add new line button. Now WaitForElementPresent Keyword will be appended into our existing script.




Now assume I want to read caption "Google.lk offered in: සිංහල தமிழ்" exists in the page. For this I use Fire path spy to identify the object of the caption.



Then I use ValidateObjactValue keyword. I pass expected result of  "Google.lk offered in: සිංහල தமிழ்" into Value Textbox and select Locator type as ID and Object ID into Object Textbox and click Add new line button



Now I am going to save the test script as My First Test and Project as My First Project and run the script using Run Script Button. Just to show the fail scenario, I have changed the expected results of ValidateObjactValue. Now I am expecting a Fail in ValidateObjactValue. 

Now you can see the detail test log in Log section and Summary as a pie chart.