Wednesday 26 February 2014

Here are some lists of objects that are frequently used in VB Script:

Set objEmail = CreateObject( “CDO.Message” )
Set objIE = CreateObject( “InternetExplorer.Application” )
Set objInet = CreateObject( “InetCtls.Inet.1″ )
Set objHTTP = CreateObject( “WinHttp.WinHttpRequest.5.1″ )
Set objExcel = CreateObject( “Excel.Application” )
Set objExcelSheet = CreateObject( “Excel.Sheet” )
Set objOutlook = CreateObject( “Outlook.Application” )
Set objPpt = CreateObject( “PowerPoint.Application” )
Set objWord = CreateObject( “Word.Application” )
Set objCal = CreateObject( “MSCAL.Calendar” )
Set objQPro = CreateObject( “QuattroPro.PerfectScript” )
Set objWP = CreateObject( “WordPerfect.PerfectScript” )
Set objConn = CreateObject( “ADODB.Connection” )
Set objRecSet = CreateObject( “ADODB.Recordset” )
Set objDic = CreateObject( “Scripting.Dictionary” )
Set objFSO = CreateObject( “Scripting.FileSystemObject” )
Set wshNetwork = CreateObject( “WScript.Network” )
Set wshShell = CreateObject( “WScript.Shell” )
Set objRandom = CreateObject( “System.Random” )
Set objArrList = CreateObject( “System.Collections.ArrayList” )
Set objSortList = CreateObject( “System.Collections.SortedList” )
Set xmlDoc = CreateObject( “Microsoft.XmlDom” )
Set xml2Doc = CreateObject( “Msxml2.DOMDocument.5.0″ )
Set objiTunes = CreateObject( “iTunes.Application” )
Set objPlayer = CreateObject( “WMPlayer.OCX” )
Set objWMPlayer = CreateObject( “WMPlayer.OCX.7″ )
Set objReal = CreateObject( “rmocx.RealPlayer G2 Control.1″ )
Set objFSDialog = CreateObject( “SAFRCFileDlg.FileSave” )
Set objFODialog = CreateObject( “SAFRCFileDlg.FileOpen” )
Set objDialog = CreateObject( “UserAccounts.CommonDialog” )
Set SOAPClient = CreateObject( “MSSOAP.SOAPClient” )
Set objWOL = CreateObject( “UltraWOL.ctlUltraWOL” )
Set objSearcher = CreateObject( “Microsoft.Update.Searcher” )
Set objShell = CreateObject( “Shell.Application” )
Set objDeviceReplay=CreateObject(“Mercury.DeviceReplay”)


--Sudhakar.Mangi

Sunday 23 February 2014

A day in my test-life...using my test tools!

A day in my test-life...using my test tools

08.00 Arrives at work, connects (dual monitors) and starts my laptop.
08.08 Logged in at last (crypted hard drives)!
08.09 Check emergency e-mail from production or test (if any)
08.10 Check status for all ten test environments (available in i single web page, VBScript-based)
08.11 Test environment maintaince
08.20 Check regression test dashboard (available in i single web page, VBScript-based) wheather to start some automated test suites or not
08.30 Check for bug fixes and new builds
08.31 Retesting bugs
09.15 Short test meeting regarding release status
09.30 Manual test session based on my product areas in the release (using my test tools for test data).
11.30 Peer reviews with testing team
12.15 Maintainance of test frameworks(using different tools)
13:00 Lunch
14.00 Manual test session based on my product areas in the release (using my test tools for test data)
17.00 Going home

This is of course in case all things runs smoothly...

:-) 

QTP: Test execution performance!!

One of my Web Service test suites has 174 test cases and it takes QTP... 7 minutes to execute them all. At first it may seems to be a resonable amount of time, especially compared to simular GUI operations which would have taken hours in test execution.

When I execute the same test suite running as a vbs-file instead I'm down to 1 minute and 45 seconds!

What are the differences? The code is the same apart from that all QTP specific log functions like Reporter are replaced by custom logging to files (which should be slower since 1 folder and 2 xml-files are created for each test case).

My conclusion is that QTP has a lot of overhead features which affects test execution performance in a negative way, especially considering that must features are not that useful in the long run (at least not for me).

Ps. My QTP settings are Run mode "fast" and no QTP recovery scenario is involved 

Agile Testing..what i thoughts!!!!!!!!!!!










Sudhakar.M

Friday 14 February 2014

Measuring the response time using a timer in Selenium !!

Measuring page load or response time is one of the basic metrics that we can capture 
in the Selenium WebDriver tests. We can use timers in the test code to capture 
the time taken for page load, rendering of the elements, JavaScript code execution, 
and so on. This approach can be implemented using the Date/Time classes 
in programming languages.


We will use the System.currentTimeMillis()

method to get the current time as follows:


// Get the Start Time
long startTime = System.currentTimeMillis();
// Open the BMI Calculator Mobile Application
driver.get("http://dl.dropbox.com/u/55228056/bmicalculator.html");
// Wait for the Calculate Button
new WebDriverWait(driver, 10).until(ExpectedConditions.
presenceOfElementLocated(By.id("Calculate")));
// Get the End Time
long endTime = System.currentTimeMillis();
// Measure total time
long totalTime = endTime - startTime;
System.out.println("Total Page Load Time: " + totalTime + "milliseconds");


Sudhakar.Mangi

Tuesday 11 February 2014

How to draw a chart in Excel using VBScript?

A picture is worth a thousand words–Napoleon Bonaparte.

Yeah! It sounds great; but it needs an effort to display thousand words into a single image,well, i am talking about drawing chart in excel.
Sometimes, i wonder why not QTP provide all this features;How nice it would be; entering range of values in the data table and just on a single click desired type of graph would be generated.
It’s often said that “Hope makes life more interesting to live” :)
It would be easier to display our automation test coverage in a graphical format to our stakeholders.we can achieve it as follows;

Steps to be performed:
Create an Instance of Excel–>Add a workbook–>Add a sheet–>Add range of datas–>Select range of datas–>Add a chart–>Populate data–>format a chart–>Display a graph.

'**********************************************
'Function: CreateChart()
'Description:Creates a graph in an excel sheet.
'****************************************************
Function CreateChart()
On Error Resume next
Dim oExl,oWrkbk,oWrkst,oMychart
Set oExl=CreateObject("Excel.Application")
With oExl

        .Visible=True
End With
Set oWrkbk=oExl.Workbooks.Add()
Set oWrkst=oWrkbk.Worksheets(1)

With oWrkst
.Cells(1,1)="Critical"
.Cells(2,1)="Very Serious"
.Cells(3,1)="Serious"
.Cells(4,1)="Moderate"
.Cells(5,1)="Mild"

.Cells(1,2)="Bugs Severity"

For i=2 to 5

.Cells(i,2)=i+21

 If i>4 Then
 .Cells(5,2)=9
 End If

Next
End With
Set oRange=oWrkst.UsedRange
oRange.Select
Set oChart=oExl.charts
oChart.Add()
Set oMychart=oChart(1)
oMychart.Activate
oMychart.ChartType=5
oMychart.ApplyDataLabels 5

oMychart.PlotArea.Fill.Visible=False
oMychart.PlotArea.Border.LineStyle=-4142
oMychart.SeriesCollection(1).DataLabels.Font.Size=15
oMychart.SeriesCollection(1).DataLabels.Font.ColorIndex=2

oMychart.ChartArea.Fill.Forecolor.SchemeColor=49
oMychart.ChartArea.Fill.Backcolor.SchemeColor=14
oMychart.ChartArea.Fill.TwoColorGradient 1,1

oMychart.ChartTitle.Font.Size=20
oMychart.ChartTitle.Font.ColorIndex=4
'oWrkbk.Close
Set oExl=Nothing

If err.number<>0 then

 Msgbox "error occurred while drawing..."
 Msgbox err.Description

Else

 Msgbox  "Successfully drawn"

End If

End Function


CreateChart()

Thank You 
Sudhakar.Mangi

OUTPUT:

See the Magic....

Simple trick for Page Scroll in QTP!!

Syntax:
object .doScroll(“Scrollingaction”)
Scrolling Actions:
1.Up
2.down
3.pageUp
4.pageDown
5.pageLeft
6.pageRight and many more….

Function Scroll()
Browser(“micclass:=Browser”).Page(“micclass:=Page”).Sync
Set oDoc=Browser(“micclass:=Browser”).Page(“micclass:=Page”).Object.Body
oDoc.doScroll(“pageDown”)
Set oDoc=Nothing

End Function

Tuesday 4 February 2014

Is VB Script Supports OOPS Concept !!!!!!!!!!!!!!!!!!!!

My answer for this is No but Yes.
To supports the OOPs concept, the script needs to be satisfy the OOPs principles.

OOPS Principles -
1.Encapsulation
2.Inheritance
3.Polymorphism

Lets write a script to satisfy each principle -

Encapsulation - The wrapping of data and function into a single unit (Called class) is known as Encapsulation.

Example -

Class Maths

Function add(a,b)
MsgBox "Sum = "&a+b
End Function
End Class

Set Mat=New Maths
res=Mat.add (2,3)

'************************************************************************************

Inheritance - It is the process by which object of one class acquire the properties of object of another class.

'Example -

Class Outer
Function test()
Set inn= New Inner
inn.display
End Function

End Class

Class Inner 
Function display()
MsgBox "This is inner class"
End Function
End Class

Set out=New Outer
out.test()

'************************************************************************************

'Polymorphism - Polymorphism means the ability to take more than one form/methods

Example -

Dim idno, name, marks
Class Student

Function SetData()
idno="10"
name="arun"
marks="300"
End Function

Function getData()
MsgBox "Idno "&idno
MsgBox "Name "&name
MsgBox "Marks "&marks
End Function

End Class

Class Student2

Function SetData(a,s,m)
idno=a
name=s
marks=m
End Function

End Class 

Set Std1=New Student
std1.SetData()
std1.getData()
Set std2=New Student2
std2.SetData "12","Singh","400"
std1.getData()


I am trying to say Yes, it supports OOPS concept. But if any body is having any questions or my assumption is wrong then please post here as a comments.


--sudhakar.Mangi

Sunday 2 February 2014

Using Wrapper classes in QTP!!!!!!!!!!!!!!

One of my biggest complaints with VBScript is the lack of inheritance/interfaces. I know, I know...it's a scripting language and I am asking a lot. It wasn't my choice, however, to use this language as the one that drives QTP (and other testing tools). 

I hear some of you groaning about me preaching objects again, but I don't mind. You go on ahead an groan. :-)

My complaint stems from the fact that we cannot inherit and extend objects in VBScript like I would like to be able to do. As I've mentioned in prior posts, being able to create the myBrowser class from the QTP browser would rock. You can, as I've also previously noted, extend the interface of an object some using function libraries and registering functions to given objects. This works, but it's not as tidy as I'd like it to be. It also seems to be fragile somehow, mostly because it's not as encapsulated as I'd like it to be.

So, if you want to extend objects and don't like the user function idea (although I use it lot), how do you proceed?

Simulated inheritance. 

What is it? It's done using a wrapper in VBScript. If I use a wrapper, I can have as many objects wrapped up together as one cohesive unit and the user will never even know I've done it (probably). For example:

Let's assume I want to create a class that contains a lot of the functionality of 2 other objects, one of which has a name property and one of which has a number property. I could do this:

Class myNewClass

    Dim myParentObject1
    Dim myParentObject2

    Public Property Get Name()
       Name = myParentObject1.Name
    End Property

    Public Property Let Name(ByVal Value)
       myParentObject1.Name = Value
    End Property

    Public Property Get Number()
       Number = myParentObject1.Number
    End Property

    Public Property Let Name(ByVal Value)
       myParentObject1.Number = Value
    End Property

End Class

See? The caller of my class will only see the public interface for the wrapper:

Dim myObject

Set myObject = NewMyNewClass 'See previous post about objects on why this looks like does

myObject.Name = "Theo"
myObject.Number = 42

Additionally, I can write some code in the wrapper that might improve/change the functionality of the "base" class. A good example of this is a class I built recently that gives me the power of a Dictionary object's associative recall with the next/previous/movefirst/movelast functionality of DataSets. I can now either get the values out of the dictionary via a key or iterate it. Can I interate it using the Keys array off the object? Sure, but if I wrap this up, then it becomes simple and standard using a Do/Loop

Now, this is NOT inheritance. I may even be treading on toes using the term "simulated inheritance". Please don't tell anyone I said that VBScript supports inheritance. 

Where this really falls down, though, is when you want to build an object hierarchy. Imagine that your class contains a class that contains a class.....merely setting a property would be a royal pain. My advice? Keep the wrapper classes no more than one object level deep. Sure, use three objects on the same level, but avoid going any deeper.

Until QTP ships with a fully OOP language for scripting (like Rational Functional Tester does...it uses either .Net or Java), this is about the best we can do.

Sudhakar.Mangi