Friday, January 09, 2009

Microsoft Tag

 

Yesterday, Microsoft released a very amazing Microsoft Tag Beta. The Microsoft Tag application uses camera of your Internet-capable mobile phone to snap a tag, which will quickly and easily connect to mobile content such as online contents, dialing information, vCards etc without having to type anything.

These Tags can be included on all kinds of material: paper handouts, vCards, T-shirts, magnets, online displays and even dog tags

You can download the free Microsoft Tag reader application (http://gettag.mobi) to your Internet-capable mobile device with camera, launch the reader and read a tag using your phone’s camera. Depending on the scenario, this triggers the intended content to be displayed, data to be integrated, e-mail to be sent and so on. It’s very cool.

I tried creating couple of tags for myself and here is one which will open my blog site in your mobile once you install Tag application.

MyBlogTag

Or use this to call my cell phone

untitled Microsoft has developed this solution as a Marketing tool, however this will turn-out in a great mobile productivity tool.

Thursday, April 05, 2007

Using .NET Classes in VBScript

Using COM Interop we can use COM Classes in .NET or .NET Classes in COM supported languages. I had a test scenario where we wanted to test the sorting feature in application under test. AUT displays data in a table and each column of this table can be sorted in Ascending or Descending Order.

Instead of writing custom sorting logic I used System.Collections.ArrayList class which has inbuilt sorting algorithm and binary search capability. This also gives optimized performance over the conventional methods.

VBScript Code:
 
Dim myList    
Set myList = CreateObject("System.Collections.ArrayList")    
    
'//Add items to ArrayList using ArrayList.Add method     
myList.Add("Test123")    
myList.Add("hello")    
myList.Add("Zx")    
myList.Add("zA")    
myList.Add("ab")  
  
'//Sort the contents of Array list Using ArrayList.Sort method  
List.Sort  
'//Display the sorted List   
For intCnt = 0 to myList.Count - 1  
	'//You need to strictly typecast the intCnt (Index) to integer   
 	strMsg = strMsg & myList.Item(CInt(intCnt)) & vbCrLf  
Next  
MsgBox strMsg

System.Collections.ArrayList class comes with a method BinarySearch which can not be called in VBScript Code (with CreateObject way).


BinarySearch method returns the index for given item in the ArrayList, for example myList.BinarySearch(CStr("hello")) will return 1 as index. ArrayList's use zero based indexes.


However you can use BinarySearch method using DotNetFactory.CreateInstance in Mercury QuickTest Pro.


There are many .NET classes that you can use to enhance your scripts.

Tuesday, July 12, 2005

Using Multithreading and ADODB in Ruby

Here is an example of using ADODB and multithreading in Ruby. I used this to test two different databases at the same point of time for concurrency.
require 'win32ole' 
$rsOne = WIN32OLE.new('ADODB.Recordset') 
$rsTwo = WIN32OLE.new('ADODB.Recordset') 
# Data structure to hold DSN Names 
dbs = %w( Test1 #DSN 1 - For SQL Server 
Test2 #DSN 2 - For Oracle
) 
threads = [] 
for db in dbs  
	threads << Thread.new(db) { |myDB|  
	puts "Start Time >> " << (Time.now).to_s  
	$con = WIN32OLE.new('ADODB.Connection')  
	$con['connectionstring'] = myDB  
	$con.open   
	if myDB == 'Test1' then   
		$rsOne = $con.execute('SELECT UserName FROM tblUser')  
	elsif myDB == 'Test2' then   
		$rsTwo = $con.execute('SELECT UserName FROM tblUser')  
	end   
	puts "End Time >> " << (Time.now).to_s  
	} 
end 
# Here it will create two threads at the same point of time and fetch the SELECT query results 
# into two different recordsets and compare these recordsets with each other 
threads.each { |aThread| aThread.join } 
until $rsOne['eof'] == true and $rsTwo['eof']== true  
	# Checking first field only, add additional until loop for all columns  
	# with the help rs.Fields.Count property to check all the columns   
	if $rsOne.Fields(0).Value == $rsTwo.Fields(0).Value then   
		puts $rsOne.Fields(0).Value << "=" << $rsTwo.Fields(0).Value  
	else   
		puts $rsOne.Fields(0).Value << "<>" << $rsTwo.Fields(0).Value  
	end  
	$rsOne.MoveNext()  
	$rsTwo.MoveNext() 
end

Tuesday, March 15, 2005

Microbehaviors in Test Automation

***** Test Messy with Microbehaviors I saw this at James Bach's blog, it talks about implementing Microbehaviours in Test Automation.

Monday, March 07, 2005

Testing with Water (Watir)


Watir (Web Application Testing in Ruby) – yet another tool for automated testing. Watir is an open source automated testing tool for testing Web Applications. WATIR uses the Ruby scripting language and Internet Explorer's COM Interfaces for driving test scripts in IE. Currently, Watir supports only Internet Explorer.

This free to use tool is available for download @ http://www.openqa.org/watir/

You need to install Ruby scripting language before using this tool. You can get the latest version of Ruby scripting language from http://rubyforge.org/frs/?group_id=167

What’s Ruby

Ruby is an interpreted scripting language for quick and easy object-oriented programming created by Yukihiro Matsumoto. It has many features to process text files, multithreading, and can be used to automate system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable. And it’s totally free.

Find more about ruby here http://www.ruby-lang.org/en

Watir…

Watir is a an easy to learn tool, you simply write the scripts in Ruby and tell the Watir controller to run these scripts. It does not have recording features like WinRunner or QuickTestPro tools (Now WatirRecorder is available @ http://www.openqa.org/watir-recorder/). It does not maintain any GUI map file or GUI object repository. It understands the objects based on their property values programmatically supplied by the scripter. You program the script on how to recognize the objects and perform operations on these objects. To do this you need to know the internals of a web page that you are testing. You need to know what objects are used and their identification properties etc. And then use these property values for identification and operation on these objects.

Here is an example of simple Watir script, which opens Microsoft Corporate Site and searches for Internet Explorer Development Home Page Link and opens Internet Explorer Development Home Page.

Test1.rb - Demo Watir Script

#Author: Unmesh Gundecha  
   
#This script opens Microsoft Corporate Site and searches for Internet Explorer String   
#and opens Internet Explorer Development Home Page.  
   
#requires:  
require 'watir'  
   
#includes: 
include Watir 
  
#variables: 
testSite = 'http://www.microsoft.com' 
  
#open the IE browser: 
$ie = IE.new 
  
puts "## Begining of test: Microsoft Search" 
puts " " 
puts "Step 1 : Go to the test site: " + testSite 
$ie.goto(testSite) 
puts "Action: entered " + testSite + " in the address bar." 
 
puts "Step  Put 'Internet Explorer' in the search text field" 
$ie.textField(:name,"qu").set("Internet Explorer") 
puts "Action: entered 'Internet Explorer' in the search text field" 
puts "Step  click the 'Search' button" 
  
$ie.button(:name, "msviGoButton").click # "msviGoButton" is the name of the button 
  
puts " Action: clicked the Search button." 
puts "Expected Result: " 
puts " - a Search page with results should be shown. 'Internet Explorer Developer Center' should be on the list." 
puts "Actual Result: Check that the 'Internet Explorer Developer Center' link appears on the search results page" 
  
a = $ie.pageContainsText("Internet Explorer Developer Center") 
  
if !a then 
	puts "Test Failed! Could not find: Internet Explorer Developer Center" 
else 
	puts "Test Passed. Found the test string: Internet Explorer Developer Center. Actual Results match Expected Results." 
	puts "Step  Click on Internet Explorer Developer Center link" 
	$ie.link(:text, "Internet Explorer Developer Center").click 
	puts "Action: clicked 'Internet Explorer Developer Center' link in the results list" 
	puts "Actual Result: Check that the 'Internet Explorer Developer Center' site is opened in Browser Window" 
	pageTitle = $ie.getDocument.titleputs 
	if pageTitle == 'Internet Explorer Developer Center' then 
		puts "Test Passed. Found the title string: Internet Explorer Developer Center. Page Opened" 
	else 
		puts "Test Failed! Could not find: Internet Explorer Developer Center Home Page" 
	end 
end 
  
puts " " 
##End of test: Microsoft search" 
puts 
# -end of simple Microsoft search test 




Execute this file at command prompt as C:\Test1.rb



You can do parameterization of tests using the DBI and File I/O functions on Ruby Language. You can access Excel through Win32Ole in Ruby.



Another great resource to know more about Ruby and Watir http://www.rubygarden.org/ruby?WebTestingWithRuby



DeveloperIQ Magazine, India has published my article on WATIR in June 2005 edition. This magazine is available in India and selected countries world over.




Recently I had given a presentation on WATIR tool in Computer Society of India, Pune Chapter’s Annual Event “Insights 2005” held at Hotel Le Meridian, Pune, INDIA.