Wednesday, December 7, 2011

Excel Sheet Automation Fundamental


 #cs
 Project: Existing Project Name
 Criterion: AutoIt Scripting
 Purpose: To automate "Scenario Name" script test case
 Start Date: 12:10:2011
 Modify Date: 12:10:2011
 Author: Prashant Chauhan
 #ce

 #include <WindowsConstants.au3>
 #include <GuiConstantsEx.au3>
 #include <GuiTab.au3>
 #include <Misc.au3>

 ; There is some code for making excel sheet

 #include <Excel.au3>
 #include <File.au3>
 #include <array.au3>
 #include <Date.au3>

 $STime =  _DateTimeFormat( _NowCalc(),1)

  global $sFilePath = @WorkingDir & "\." & ".\result\Result.xls"
  _ExcelBookOpen($sFilePath)
  $oExcel = _ExcelBookAttach($sFilePath)

  $pass_count=0
  $fail_count=0
  $start=TimerInit()
  $logwrite = FileOpen(@WorkingDir & "\." & ".\result\Result.log", 1)
  FileWriteLine($logwrite,"")
  FileWriteLine($logwrite,"===== TC_createProjectFolder =====")
  FileWriteLine($logwrite,"")
 
  ;Run ("C:\ Path \*.exe")
  DirRemove("C:\ *.* ",1)

 WinSetState("Title","",@SW_MAXIMIZE)

  If WinExists("[TITLE:*; CLASS:*; INSTANCE:1]", "") Then
   FileWriteLine($logwrite,"Fail : The folder is not added to the project with the given name")
   _ExcelWriteCell($oExcel, "Fail : The folder is not added to the project with the given name", 5, 9)
   $oExcel.Activesheet.Range("I5").Font.ColorIndex = 3


;Red color=3, Green color=10, "I5" means- I for column and 5 for row


   $fail_count=$fail_count+1
  Else
   FileWriteLine($logwrite,"Pass : The folder is added to the project with the given name")
   _ExcelWriteCell($oExcel, "Pass : The folder is added to the project with the given name", 5, 9)
   $pass_count=$pass_count+1
  EndIf

 Sleep(2000)
 WinClose("[TITLE:*; CLASS:*; INSTANCE:1]", "")
 Sleep(1000)

 WinWaitActive("Modified Files")
 
  If WinExists("Modified Files") Then
   Send("{TAB}")
   Sleep(1000)
   Send("{ENTER}")
  EndIf
 
   $dif = TimerDiff($start)
   $Time = Round($dif/1000,2)
 
 FileWriteLine($logwrite, "Pass: "&$pass_count&"    Fail: "&$fail_count&"      Time: "&$Time&" Sec" )
 FileWriteLine($logwrite,"")
 FileClose($logwrite)

 _ExcelWriteCell($oExcel, $Time, 5, 12)
 ;_ExcelWriteCell($oExcel, '3', 5, 1)
 ;_ExcelWriteCell($oExcel, "TC_createProjectFolder", 5, 2)
 _ExcelWriteCell($oExcel, $STime, 5, 14)
 ;_ExcelBookClose($oExcel, 1, 0)

2 comments:

  1. Hello Prashant,
    The Article on Excel Sheet Automation Fundamental is nice. It give detail information about it .Thanks for Sharing the information on Automation Fundamental is nice.
    Software Testing Company

    ReplyDelete
  2. HI,

    Thank you so much for posting this. I really appreciate your work. Keep it up. Great work!

    http://kosmiktechnologies.com/selenium/

    ReplyDelete