Friday, April 17, 2009

OTA : Test Case Upload in QC

Public oWorkbook
Public oSheet
Public sWorkbook
Public intShtCnt
Public wrkbk
Public intArrCnt
Public wrkbk1
Public strTestCaseDescription
Public strDesSteps(10)
Public StrExpRes(10)
Public strStepCnt(10)
Public iRowCnt2
Public iRowCnt1
Public strExcelPath
Public strTestCaseName

Public strConfg(10)
Public td
Public tf
Public tstCase
Public dsf
Public ds

iRowCnt1 = 2
iRowCnt2 = 8

'*****************************************************************************************************
' Create the Excel Object required for reference
'*****************************************************************************************************'

public Function create()
Set app = createobject ("Excel.Application")
Set create = app
End Function

'*****************************************************************************************************
' Open the Excel File using the object created
'*****************************************************************************************************'

Public Function open()
Set wrkbk = create.Workbooks.Open(strExcelPath)
Set oSheet = wrkbk.WorkSheets
Set open = wrkbk
Set oSheet = Nothing
Set wrkbk = Nothing
End Function



'*****************************************************************************************************
'Kill all the open Excel Process
'*****************************************************************************************************'

Public Function Kill_Executable(Exe_Name)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '"&Exe_Name&"'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
Set colProcessList = Nothing
Set objWMIService = Nothing
End Function


'*****************************************************************************************************
'Terminate all the object created
'*****************************************************************************************************'

Public Function Class_Terminate()

Set app = Nothing
Set oSht = Nothing
Set oSheet = Nothing
Set wrkbk = Nothing
Call Kill_Executable("EXCEL.EXE")


End Function

'*****************************************************************************************************
'Read data from excel file and create an input array with all expected results
'*****************************************************************************************************'

Public Function readFromExcel()
strExcelPath = strConfg(5)
intArrCnt = 0
Dim strStepValue
Set oSht = open.Sheets(2)
strTestCaseName = (oSht.Cells(iRowCnt1,2))
Do while strTestCaseName <> ""
strTestCaseDescription = (oSht.Cells(3,2))
strTestCasePath = (oSht.Cells(4,2))
strStepValue = (oSht.Cells(iRowCnt2,1))
Do while strStepValue <> ""
strStepCnt(intArrCnt) = (oSht.Cells(iRowCnt2,1))
strDesSteps(intArrCnt) = (oSht.Cells(iRowCnt2,2))
StrExpRes(intArrCnt) = (oSht.Cells(iRowCnt2,3))
iRowCnt2 = iRowCnt2 + 1
intArrCnt = intArrCnt + 1
strStepValue = (oSht.Cells(iRowCnt2,1))
Loop
Set oSht = Nothing
Exit Do
Loop
End Function


'*****************************************************************************************************
'Read data from text file regarding the QC URL and Login Details and Excel Folder Path
'*****************************************************************************************************'

Function readTextFile()
Const ForReading = 1
Dim i
Dim strTextArr
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\testTq.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strTextVal = objTextFile.Readline
strTextArr = Split(strTextVal,"=")
strConfg(i) = trim(strTextArr(1))
i = i + 1
Loop
End Function


'*****************************************************************************************************
'Upload the array elemenrts obtained from the Excel into the Quality Center.
'*****************************************************************************************************'

Function uploadQC()

Set td=createobject("TDApiOle80.TDConnection.1")
td.InitConnectionEx strConfg(0)
td.ConnectProjectEx strConfg(1),strConfg(2),strConfg(3),strConfg(4)

Set tstMgr = td.TreeManager
Set tsttr = tstMgr.NodeByPath(strTestCasePath)

'Creste testFactory object
Set tsetFact = tsttr.TestFactory

'Create new test with the sheet name
Set tstCase = tsetFact.AddItem(strTestCaseName)
tsetFact.Field("TS_DESCRIPTION") = strTestCaseDescription
'Post the new test case
tstCase.Post

'Create design steps factory object
Set dsf = tstCase.DesignStepFactory
'Iterate for the number of steps in the excel sheet
For m = 1 to intArrCnt-1

'Add individual steps into design steps along with step number, step description and expected result
Set ds = dsf.AddItem(Null)

ds.Field("DS_STEP_NAME") = strStepCnt(m)
ds.Field("DS_DESCRIPTION") =strDesSteps(m)
ds.Field("DS_EXPECTED") = StrExpRes(m)
ds.Post

Next

End Function


'*****************************************************************************************************
'Function Calls to Upload manual test cases from excel into QC
'*****************************************************************************************************'

Call readTextFile()
Call Class_Terminate()
Call readFromExcel()
Call Class_Terminate()
Call uploadQC()

45 comments:

Anonymous said...

This is simply Execellent, execellent,Excellent

ebe.mca@gmail.com

Jonty... said...

Thanks

Anonymous said...

Very well explained. I tried the code but I am getting "Unable to post" error

Jonty... said...

what line the error comes?
What is the exact error?

Anonymous said...

This is very good....could you also please share the sample data files used

Jonty... said...

Share your mail ID.

Anonymous said...

Could you please share the data files used ...
roopaautomation@yahoo.com

Thanks,
Roopa

Anonymous said...

This is great!!!
Can you please share the sample data files used for this sample.
Thanks
dob85@yahoo.com

Sathish Murugiah said...

This is great; Can you please share the template, appreciate your help.

Sathish Murugiah said...

I request you to send it to satz.sakius@gmail.com

Amin said...

Could you please share the sample excel?
amin_nyc@yahoo.com

OLEHELP said...

Hi,
This seems to be very useful,
I am trying to use this code but no success... :(
could you please send me template & the sample data files used for this.
Email id is : olehelp2011@gmail.com
Thanks a lot in advance.

Anonymous said...

Excellent work.Please share the template & the sample data files. It would be of great help.
mudayashankar@gmail.com

Smith said...
This comment has been removed by the author.
Smith said...
This comment has been removed by the author.
Smith said...
This comment has been removed by the author.
Smith said...

This is a greate post
could you also please share the sample data files used
Email: smith.ccontact@gmail.com

Thanks

learnqtp said...

Hi, excellent post..

Please explain why the following is written in code
iRowCnt1 = 2
iRowCnt2 = 8

i am facing issue in understanding the the function readfrom excel()

can you pls explain it and share the related test case file at:

guptaamit118@gmail.com

Anonymous said...

[url=http://loveepicentre.com/taketour.php][img]http://loveepicentre.com/uploades/photos/11.jpg[/img][/url]
christian dating service atlanta [url=http://loveepicentre.com/articles.php]dating for maine people[/url] manhattan dating services
antartic radioactive dating of meteorites [url=http://loveepicentre.com/]hot dating in uk[/url] nick cannon dating miss usa
transsexual dating in alabama [url=http://loveepicentre.com/]online dating relationship[/url] uban love dating site

Anonymous said...

[url=http://loveepicentre.com][img]http://loveepicentre.com/uploades/photos/6.jpg[/img][/url]
chat lines dating [url=http://loveepicentre.com/testimonials.php]teen dating sex advice[/url] dating lonely wife
teacher dating message boards [url=http://loveepicentre.com]gamers oline dating[/url] nude ukranian dating
rush limbaugh is dating [url=http://loveepicentre.com/advice.php]dating montreal annabelle gagne[/url] singles around the world dating community

Anonymous said...

ebook life application study bible http://audiobookscollection.co.uk/fr/Evelyne-Tournier/m36777/ victor davis hanson ebook [url=http://audiobookscollection.co.uk/it/Your-Body-How-It-Works-The-Circulatory-System/p117069/]recover ebook clients username passwprds[/url] ebook edward bernays propaganda

vaibhav said...

Can you please share the data files on the id Mentioned here ...this is very nice example and solved lot of my problems related to QC upload.

Email: mailmevaibhavbapat@gmail.com

vaibhav said...

Can you please share the data files on the id Mentioned here ...this is very nice example and solved lot of my problems related to QC upload.

Email: mailmevaibhavbapat@gmail.com

Anonymous said...

glance software http://buyoemsoftware.co.uk/fr/product-36194/Microsoft-Windows-7-Ultimate-x64-French get ebook software [url=http://buyoemsoftware.co.uk/product-31822/MS-SQL-Server-Automatic-Backup-and-Restore-Software-7-0]garmin nuvi 310 radar detection software[/url] branch suite credit union software
[url=http://buyoemsoftware.co.uk/product-15088/Giant-Disk-Cleaner-1-9]Giant Disk Cleaner 1.9 - Software Store[/url] grammar check software
[url=http://buyoemsoftware.co.uk/de/product-33535/Digital-Anarchy-Beauty-Box-1-0-for-Adobe-Photoshop][img]http://buyoem.co.uk/image/7.gif[/img][/url]

SHOBHIT DEWAN said...

hi could you please share the data files (txt file and excel) used at shobhitdewan2212@gmail.com
Thanks,
SD

Anonymous said...

[url=http://redbrickstore.co.uk/products/sinemet.htm][img]http://onlinemedistore.com/7.jpg[/img][/url]
east tao herb pharmacy http://redbrickstore.co.uk/products/prinivil.htm pharmacy internet [url=http://redbrickstore.co.uk/categories/arthritis.htm]canada pharmacy[/url]
prescription pharmacy http://redbrickstore.co.uk/products/amitriptyline.htm nova southeastern university college of pharmacy [url=http://redbrickstore.co.uk/products/uroxatral.htm]uroxatral[/url]
industrial chemistry studied in faculty of pharmacy in egypt http://redbrickstore.co.uk/products/pepcid.htm palmyra nj pharmacy [url=http://redbrickstore.co.uk/products/famvir.htm]providence st vincent hospital portland pharmacy[/url]
pharmacy laws in florida http://redbrickstore.co.uk/products/rogaine-5-.htm tower online pharmacy [url=http://redbrickstore.co.uk/products/micardis.htm]micardis[/url]

Anonymous said...

[url=http://certifiedpharmacy.co.uk/catalogue/u.htm][img]http://onlinemedistore.com/10.jpg[/img][/url]
health care screening in pharmacy practice http://certifiedpharmacy.co.uk/products/provera.htm pharmacy technicians in ohio [url=http://certifiedpharmacy.co.uk/products/vantin.htm]pharmacy coumpounding sources[/url]
on the job training in washington for pharmacy technicians http://certifiedpharmacy.co.uk/products/furosemide.htm doctors consultation pharmacy [url=http://certifiedpharmacy.co.uk/products/trazodone.htm]trazodone[/url]
usa pharmacy acne fedex http://certifiedpharmacy.co.uk/products/hard-on.htm pharmacy tech programs in houston [url=http://certifiedpharmacy.co.uk/products/leukeran.htm]pharmacy technician practice test[/url]
discount pharmacy macquarie shops act http://certifiedpharmacy.co.uk/products/zelnorm.htm overseas pharmacy scams [url=http://certifiedpharmacy.co.uk/products/terramycin.htm]terramycin[/url]

Anonymous said...

morefish dating http://loveepicentre.com/advice/ free mobile dating chatting
who is miley cyrus dating [url=http://loveepicentre.com]lesbian dating atlanta[/url] australia dating site asap
free asian dating and san diego [url=http://loveepicentre.com/advice/]tell me more about speed dating[/url] meeting christian people for dating [url=http://loveepicentre.com/user/NailDriver/]NailDriver[/url] england adult dating sites

Anonymous said...

I am in fact grateful to the owner of this web page who has shared this enormous article at at this time.


Here is my blog post - Christian Louboutin Heels ()

Anonymous said...

I don't know if it's just me or if everybody else encountering
issues with your site. It appears as if some of the written text on your content are running off the screen.
Can somebody else please comment and let me know if this is happening to them too?
This might be a issue with my internet browser because I've had this happen previously. Thank you

Feel free to surf to my webpage ... Air Max

Anonymous said...

What i do not understood is in fact how you're not really a lot more smartly-preferred than you might be right now. You're very intelligent.
You realize therefore considerably with regards to this matter, produced me in my view imagine it from numerous numerous angles.
Its like women and men don't seem to be involved unless it is one thing to accomplish with Girl gaga! Your personal stuffs nice. At all times take care of it up!

Feel free to surf to my blog :: Sac A Main Louis Vuitton

Anonymous said...

Usually I don't read article on blogs, but I wish to say that this write-up very pressured me to take a look at and do it! Your writing taste has been surprised me. Thank you, very nice post.

my web site ... Tory Burch Handbags

Anonymous said...

I'm extremely inspired together with your writing talents as smartly as with the layout in your blog. Is that this a paid theme or did you modify it your self? Anyway stay up the nice quality writing, it is rare to look a great weblog like this one today..

my site Cheap Jerseys

Anonymous said...

Hi, its nice article regarding media print, we all know media is a great source of
facts.

My page: Michael Kors

Anonymous said...

I visited many blogs but the audio feature for audio songs
existing at this website is genuinely fabulous.


Also visit my weblog; Michael Kors

Automation said...

Could you please share the sample data fules used?

uday.kumar.shanth@fmr.com

Shobhit said...

Plzz send the sample excel file used. I need it very badly.Send it at shobhitdewan2212@gmail.com

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi ,

Thanks for your post,

But while I am executing the code, I am getting "AUTOMATION ERROR" at sampleTest.Post.

Please help me in resolving this

ananthbulusu@gmail.com

Unknown said...

please share excel data file and text file used in this code....Email ID - amit.23.shah@gmail.com

Anonymous said...

could you pl share the excel nd data file to ptthoppil@gmail.com

swapna said...

Could you please send me the template and excel data file used in this code to chs8757@gmail.com.Thanks very much.

Unknown said...

Hi !! This is praveen. Can you please suggest/guide me how to convert ALM Manual test to quicktest test using VB scripts. Thanks in advance

Unknown said...

Can you please share the data files/template on the id Mentioned here ...this is very nice example and solved lot of my problems related to QC upload.

Email: badgujarmanoj@gmail.com

boleau said...

click now my site this hyperlink Ysl replica important source blog here