With below tow ways we can convert date fromat from current format to required date data type format.
way 1:-
Code :-
Dim xlsCurrentDate
Set xlsCurrentDate=GetObject("","Excel.Application")
MsgBox xlsCurrentDate.Text("5/27/2009", "YYYY-MM-DD")
Set xlsCurrentDate=Nothing
OUTPUT :- 2009-05-27
way 2:-
dim Val, DateConvert, formatDate
Val="5/27/2009"
DateConvert=Cdate(Val)
formatDate=Year(DateConvert)&"-"&Month(DateConvert)&"-"& day(DateConvert)
msgbox formatDate
OUTPUT :- 2009-05-27
Wednesday, May 27, 2009
Tuesday, May 12, 2009
How to get Test parameter value?
I got the information in the below site for Test parameter creation and get value.
syntax for Test paramter value retrive: TestArgs ("Test Parameter Name")
http://qtp.blogspot.com/2007/11/qtp-test-parameters_11.html
syntax for Test paramter value retrive: TestArgs ("Test Parameter Name")
http://qtp.blogspot.com/2007/11/qtp-test-parameters_11.html
Labels:
General
Sunday, May 10, 2009
How to "Save As" a existing Script with QTP code?
We can "SaveAs" saved script in Local machine and in Quality Centre with below code.
Dim QTPApp 'As QuickTest.Application ' Declare the Application object variable
Set QTPApp = CreateObject("QuickTest.Application") ' Create the Application object
QTPApp.Launch ' Start QuickTest (if not launched)
QTPApp.Visible = True ' Make it visible
QTPApp.Open “C:\Test1”,True ' Open the test in Edit mode
QTPApp.Test.SaveAs “C:\SaveAsTest” 'Save it with a temporary name (override existing temporary test)
Set QTPApp = Nothing ' Release the Application object
Dim QTPApp 'As QuickTest.Application ' Declare the Application object variable
Set QTPApp = CreateObject("QuickTest.Application") ' Create the Application object
QTPApp.Launch ' Start QuickTest (if not launched)
QTPApp.Visible = True ' Make it visible
QTPApp.Open “C:\Test1”,True ' Open the test in Edit mode
QTPApp.Test.SaveAs “C:\SaveAsTest” 'Save it with a temporary name (override existing temporary test)
Set QTPApp = Nothing ' Release the Application object
Labels:
General
Import file with Pathfinder command.
We can import files (Excel, VBS, XML, etc.) from Local machine and Quality Center to QTP.
First we have to do settings in QTP with below navigation
Tools --> Options --> Folders and click on “+” and add specified folder path.
In code wherever we are using “Import” command there use below code.
Dim QTPApp, SearchPath
Set QTPApp = CreateObject("QuickTest.Application") ' Create the Application Object
QTPApp.Launch ' Start QTP
QTPApp.Folders.Add(“C:\FolderNmae")' Add the folder for Search list
SearchPath=pathfinder.Locate("FileName.xls") ' Locate the folder Path
datatable.ImportSheet SearchPath,1,1
set QTPApp =nothing 'Release the Application Object
First we have to do settings in QTP with below navigation
Tools --> Options --> Folders and click on “+” and add specified folder path.
In code wherever we are using “Import” command there use below code.
Dim QTPApp, SearchPath
Set QTPApp = CreateObject("QuickTest.Application") ' Create the Application Object
QTPApp.Launch ' Start QTP
QTPApp.Folders.Add(“C:\FolderNmae")' Add the folder for Search list
SearchPath=pathfinder.Locate("FileName.xls") ' Locate the folder Path
datatable.ImportSheet SearchPath,1,1
set QTPApp =nothing 'Release the Application Object
Labels:
General
Get specific node value from XML file.
We can get parent and child node values with below code.
Val=GetNodeValue ( “C:\XMLfile.XML”,"ParentNodeName","ChildNodeName")
msgbox UBound(Val)
Function GetNodeValue(XMLFilePath,ParentNode,ChildNode)
Dim Obj_Xml,str_ParentNode,list_childs
Dim i,j,str_ParentNodeCnt,str_result()
set Obj_Xml=createobject("MSXml2.DOMDocument.3.0")
Obj_Xml.load XMLFilePath
set str_ParentNode=Obj_Xml.getElementsByTagName(ParentNode)
str_ParentNodeCnt=str_ParentNode.length
ReDim str_result(str_ParentNodeCnt)
msgbox str_ParentNodeCnt
For i=0 to str_ParentNodeCnt-1
set list_childs=str_ParentNode(i).childnodes
for j=0 to list_childs.length-1
If list_childs.item(j).nodename=ChildNode then
str_result(i)=list_childs.item(j).text
Exit for
end if
next
Next
GetNodeValue=str_result
End Function
Val=GetNodeValue ( “C:\XMLfile.XML”,"ParentNodeName","ChildNodeName")
msgbox UBound(Val)
Function GetNodeValue(XMLFilePath,ParentNode,ChildNode)
Dim Obj_Xml,str_ParentNode,list_childs
Dim i,j,str_ParentNodeCnt,str_result()
set Obj_Xml=createobject("MSXml2.DOMDocument.3.0")
Obj_Xml.load XMLFilePath
set str_ParentNode=Obj_Xml.getElementsByTagName(ParentNode)
str_ParentNodeCnt=str_ParentNode.length
ReDim str_result(str_ParentNodeCnt)
msgbox str_ParentNodeCnt
For i=0 to str_ParentNodeCnt-1
set list_childs=str_ParentNode(i).childnodes
for j=0 to list_childs.length-1
If list_childs.item(j).nodename=ChildNode then
str_result(i)=list_childs.item(j).text
Exit for
end if
next
Next
GetNodeValue=str_result
End Function
Labels:
XML Automation
Subscribe to:
Posts (Atom)