strActionname = Environment.Value("ActionName")
strOperatingSystem = Environment.Value("OS")
strOSVersion = Environment.Value("OSVersion")
strTestName = Environment.Value("TestName")
strUserName = Environment.Value("UserName")
Thursday, January 22, 2009
How to Close QTP displayed message box with QTP Code?
Sub CMsgbox(strText)
Dim objShell, buttonName
Set objShell= CreateObject("WScript.Shell")
' Display the message box with message and clost itself after 5 seconds
buttonName= objShell.Popup(strText, 5, "Message Box", 0)
End Sub
MessageText= "To know, look at this message box. It will close itself"
' Call the Procedure for message display and close it.
CMsgbox MessageText
Dim objShell, buttonName
Set objShell= CreateObject("WScript.Shell")
' Display the message box with message and clost itself after 5 seconds
buttonName= objShell.Popup(strText, 5, "Message Box", 0)
End Sub
MessageText= "To know, look at this message box. It will close itself"
' Call the Procedure for message display and close it.
CMsgbox MessageText
Labels:
General
What is the Action Template and how to Create it?
Action Template:-
In our test, in every new action, if we want to include one or more statements like Headers (Author name, Creation date, Change log etc...), function calls, etc... We can create an action template(Text file) with these statements. Save it as ActionTemplate.mst in below path in local machine.
Path:- QuickTestInstallation Folder\dat folder.
Note: QTP identifying only the file name ActionTemplate.mst is recognized as an action template.
In our test, in every new action, if we want to include one or more statements like Headers (Author name, Creation date, Change log etc...), function calls, etc... We can create an action template(Text file) with these statements. Save it as ActionTemplate.mst in below path in local machine.
Path:- QuickTestInstallation Folder\dat folder.
Note: QTP identifying only the file name ActionTemplate.mst is recognized as an action template.
Labels:
General
Wednesday, January 21, 2009
Methods for Retrive Data from DB Query result
Number of Columns in DB Query Results :-
Column count= Fields.Count
Number of in DB Query Results :-
Record/Row count= RecordSet.recordcount
Get the Column value from a particualr Record :-
value= RecordSet.Fields(Index of the Column).Value
How to confirm DB (Database) connection is successfully connected?
Return value= RecordSetObjectName.State
0-- Zero represents for NOT connected successfull
1-- One represents for Successfull connection.
Sometimes Data base columns we have cast for capture values. we can do same with below query.
Select Cast(filed name as nVarchar(3000)) from table name where condition
Column count= Fields.Count
Number of in DB Query Results :-
Record/Row count= RecordSet.recordcount
Get the Column value from a particualr Record :-
value= RecordSet.Fields(Index of the Column).Value
How to confirm DB (Database) connection is successfully connected?
Return value= RecordSetObjectName.State
0-- Zero represents for NOT connected successfull
1-- One represents for Successfull connection.
Sometimes Data base columns we have cast for capture values. we can do same with below query.
Select Cast(filed name as nVarchar(3000)) from table name where condition
Labels:
DataBase Automation
XML file creation
Set objXML = CreateObject ("Microsoft.XMLDOM")
'Create our root element using the createElement method
Set objXML.documentElement = objXML.createElement("SourceNode")
'Create Element and Node
Set objsrcl = objXML.createElement ("FirstNameAttribute") objXML.documentElement.appendChild objsrcl.cloneNode(true)
Set Node = objXML.documentElement.selectSingleNode("FirstNameAttribute")
' Create Attributes and assign values
Node.setAttribute "FirstNameAttribute", " Value"
Node.setAttribute "Second", "Value"
Node.setAttribute "third", "Value"
Node.setAttribute "Fourth","Value"
Node.setAttribute "Site", "Site"
'Save the file as XML
objxml.save "C:\CreatedXML.XML"
'Create our root element using the createElement method
Set objXML.documentElement = objXML.createElement("SourceNode")
'Create Element and Node
Set objsrcl = objXML.createElement ("FirstNameAttribute") objXML.documentElement.appendChild objsrcl.cloneNode(true)
Set Node = objXML.documentElement.selectSingleNode("FirstNameAttribute")
' Create Attributes and assign values
Node.setAttribute "FirstNameAttribute", " Value"
Node.setAttribute "Second", "Value"
Node.setAttribute "third", "Value"
Node.setAttribute "Fourth","Value"
Node.setAttribute "Site", "Site"
'Save the file as XML
objxml.save "C:\CreatedXML.XML"
Labels:
XML Automation
How to Count and close all open Browsers?
' Create description for Browser
Set strBrowser=Description.Create
strBrowser("micclass").value="Browser"
Set strBrowserObject=Desktop.ChildObjects(strBrowser)
' get the Open browsers count
BrowserCnt=strBrowserObject.count
For i=0 to BrowserCnt-1
' Get the open browsers name
BrowserName=strBrowserObject(i).getroproperty("name")
' close the open browser
strBrowserObject(i).Close
Next
Set strBrowser=Description.Create
strBrowser("micclass").value="Browser"
Set strBrowserObject=Desktop.ChildObjects(strBrowser)
' get the Open browsers count
BrowserCnt=strBrowserObject.count
For i=0 to BrowserCnt-1
' Get the open browsers name
BrowserName=strBrowserObject(i).getroproperty("name")
' close the open browser
strBrowserObject(i).Close
Next
Labels:
General
How to split a text based on end of line?
Use Split function with "VbCrLf" Constraint, see the below code snippet.
text= enter text, which is having with End of line
Split(Text, VbCrLf)
text= enter text, which is having with End of line
Split(Text, VbCrLf)
Labels:
General
Monday, January 19, 2009
Get the font Size and Color of the Object
we can get Font size, Font color, Style and Font type with below code:
intFontSize=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontSize
strFontColour=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.Color
strFontStyle=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontStyle
strFontType=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontFamily
intFontSize=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontSize
strFontColour=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.Color
strFontStyle=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontStyle
strFontType=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontFamily
Labels:
General
How can we get ToolTip of the Link?
Browser("BrowserName").Page("PageName").Link("LinkName").FireEvent "onmouseover"
Wait(2)
ToolTipText= Window("nativeclass:=tooltips_class32").GetROProperty("text")
Wait(2)
ToolTipText= Window("nativeclass:=tooltips_class32").GetROProperty("text")
Labels:
General
Subscribe to:
Posts (Atom)