Tuesday, December 31, 2013

Test Execuition Using SMS/Mail


Once the task of ‘Automating’ is successfully completed and you are able to maintain the ‘Test Suite’ easily what would you like to do?
I have been always looking for chances like this to take that extra leap. Here is what I did.

I have successfully implemented the concept of executing tests by sending SMS from mobile or mail from Outlook for one of my clients!

The code works in 3 parts
Receiving SMS from mobile/mail from outlook and analyzing the message which is in predefined format
Executing a QTP test set
Replying the message results in predefined formats

Following are the uses/features of Automation through SMS/Mail which I implemented
1.       Start test
2.       Pause Test & Resume Test
3.       Stop Test
4.       Get results on mobile and mail  (different levels of detail, report format, for mobile & mail)
5.       Set configuration of Test / Test Set / Test Suite
6.    Over-riding instructions can be given for tasks that are not yet picked up
7.       Check Status of Test Execution
8.       If multiple users/mobiles are used for the same test,
1.       Their instructions will be carried out in a queue
2.       They will be applied on defined batch/test execution configuration
3.       Can check the queue of all the instructions by different users through sms/Mail
4.       Hierarchy among users tasks by using priority
9.       Confirmation of receipt of the instruction by an acknowledgement SMS (Sometimes, mobile messaging gets delayed or failed)

10.   Connects to test management tool QC and updates results if specified

Following are the steps:
Pre Requisite: A dedicated system to run the ‘ROBO’ script that analyses SMS/MAIL and does the test execution/ response part.
1.       Open an account with some sms provider (ex: ACL,BSNL)
2.       A URL will be provided by the provider on firing which messages sent from mobile can be viewed.
3.       Write a ROBOT application which continuously fires the URL and gets the messages at regular time intervals. Robot acts as a controller over test tool.
4.    Create an outlook object and read all unread mails with predefined subject
5.    Analyze the mail content
6.       Analyze the messages and continue with test execution

Below is the design for the same.




I was not able to pick up the complete code from client (its client copy right material and no part of it should be reproduced), below is just a sample of how same can be done using VBSCRIPT.

Code:

//read sms from provider
With CreateObject("InternetExplorer.Application") 
.Navigate "http://www.smscountry.com/ApiGetInbox.asp?user=<username>&passwd=<pwd>&FromDate=03/02/2012&todate=03/02/2013"
Do until .ReadyState = 4 
loop 
.visible = false 
With .document 
res_txt=.execcommand("SelectAll"  )
res_txt=.execcommand("Copy")
res_txt=.parentwindow.clipboardData.GetData("text")
end with
end with

(contd..)