Tuesday, May 6, 2014

Getting Standard/Inner Text

The code below shows how you can get the text from any standard object using diff way

Standard Examples
'Get text from a ListView - report style (for example, Windows Explorer)
Msgbox Window("C:\Program Files\Mercury").WinListView("SysListView32").GetSubItem(1,2)

'Get text from a toolbar
Msgbox Window("C:\Program Files\Mercury").WinToolbar("ToolbarWindow32").GetItem(1)

'Text of a message-box, the Static control is not in the object repository/shared object ' 'repository
set StatObj = Dialog("DlgTB").Dialog("DlgTB").Static("nativeclass:=Static","Index:=1")
Msgbox StatObj.GetROProperty("text")

Web Example
' An example for a Web Table (in the Mercury Tour site)
Set Cell = Browser("Welcome: Mercury Tours").Page("Select a Flight: Mercury").WebTable("RETURN").ChildItem(3, 2, "WebElement", 0)
Msgbox Cell.GetROProperty("innertext")

Visual Basic Example
'Retrieving the text of a label in a VB form: (There is no Test Object for a label)
Msgbox VbWindow("VBForm1").Object.Controls("Label1").caption

.NET Example
'Get the text of items in a CheckListBox (has no Test Object)
'Get run-time object reference
Set CustList = SwfWindow("Win").SwfObject(ìlst").Object

'Get Items collection
Set ListItems = CustList.get_Items()

'Get Items count
ItemsCount = ListItems.Count

'Loop over all items
For i = 0 to ItemsCount-1
text = text & ListItems.Item(i)
Next

ActiveX Example
This example will retrieve the text from the Visual Basic Flight 1A sample application's flight grid
This retrieves the flight number from the 3rd row.

VbWindow("VbWindow").VbWindow("VbWindow").AcxTable("Grid Control").Object.Row = 3
VbWindow("VbWindow").VbWindow("VbWindow").AcxTable("Grid Control").Object.Col = 0

Msgbox VbWindow("VbWindow").VbWindow("VbWindow").AcxTable("Grid Control").Object.Text

Count & Close All Browsers

QTP Script to get total count, names of all open browsers and to close them using descriptive programming.

Set ab=Description.Create
ab("micclass").value="Browser"
Set obj=Desktop.ChildObjects(ab)
Msgbox obj.count
For i=0 to obj.count-1
                c=obj(i).getroproperty("name")
                Msgbox(c)
                obj(i).Close

Next

Wednesday, April 30, 2014

How to search for a specific string in a MS Word document

The following example uses Word object methods to open a Microsoft Word Document and retrieve paragraphs from it. Then the InStr VBScript method is used to check for the word “contract.”


Example:

Dim wrdApp
Dim wrdDoc
Dim tString, tRange
Dim p, startRange, endRange
Dim searchString

‘Create the Word Object
Set wrdApp = CreateObject(”Word.Application”)
Set wrdDoc = wrdApp.Documents.Open(”C:\Temp\Word_Doc.doc”)     ‘replace the file with your MSDoc
searchString = “contract”                                   ‘replace this with the text you’re searching for

With wrdDoc
     For p = 1 To .Paragraphs.Count
          startRange = .Paragraphs(p).Range.Start
          endRange = .Paragraphs(p).Range.End
          Set tRange = .Range(startRange, endRange)
          tString = tRange.Text
          tString = Left(tString, Len(tString) - 1)                           ‘exclude the paragraph-mark
          If InStr(1, tString, searchString) > 0 Then                     ‘check if the text has the content you want
               
               msgbox “Yes! ” & searchString & ” is present”
         Exit For
          End If
     Next
.Close                    ‘close the document
End With

wrdApp.Quit      ‘close the Word application

Set wrdDoc = Nothing

Sunday, April 27, 2014

Java best practice for Selenium

1. Package declaration should start with com. and followed by your companyname
2. Class name should start with capital letter
3. Method name should start with small letter
4. Global variable name should be in capital letter and each word in name should be separated by '_'  like MAX_CAPACITY
5. Follow the following prefix data types
string - str
int - i,
float - f
long - l
double - d
List  - list
Map - map
string array -  strArr
int array - iArr

6. Variable name should be in CamelCase like getRowId, strUserNamen
7. Every object in selenium is webelement. However to use approriately in script while you have number of weblements present in pagefactory class please follow the following naming convention.

webedit - txt
webbutton - btn
link    - lnk
combo box - cbk
weblist - lst
check box - chk
frame - fra
Dialog - dlg
image - img



Friday, April 4, 2014

How to Identify objects/Web Elements Properties in Selnium

In qtp we all know how to get object/web elements properties -  using object spy.

Same with the selenium its quite easy please see diff way to find web elements properties:

1. Using Crome

This is the fast and most efficient way to find web elements. Nagivate to your app url --> right click on the web element --> select Inspect Element. please find the below screen shot.




2. Using Firefox

Right Click on web element and select Inspect Element.




You can install fire-bug add in on fire fox and find properties by right clicking on web element.



with firebug you can also copy xpath and css values by right clicking on firebug pan.
You can also use IDE. Record the business process and ide will store all object properties.

3. Using IE:

Open IE--> Navigate to URL--> Press F12

Please see the screen shot with number tag.



Thursday, April 3, 2014

Vbscript to copy files from source to dest folder


Have you ever faced a situation where you need to copy files from one location and paste them to destination location repetitively with some specific constrains. Like

I had an requirement where i need to copy 200 files from source and paste them to destination folder, only if there is no file present in dest folder. Here dest folder process the file one by one and load it to database. once all files are processed again i need to copy 200 files and paste it. continues human attention required to check destination file count reach to zero. To overcome this,  here is a simple vbscript code

This vbscript program  will check if there any file on dest folder. if it found no file then it will copy files from source to given destination path. once 200 files are copied then it will break as it goes into  if condition. You can schedule this program to run specified time.

========================================================================


Const destPATH = "D:\dest\Files\"
Const sourcePATH = "D:\source\Files\"
dim fso
dim destfolder,sourcefldr,i
i=0
set fso = CreateObject("Scripting.FileSystemObject")
set destfolder = fso.getFolder(destPATH)
set sourcefolder = fso.getFolder(sourcePATH)
               
If destfolder.files.Count <= 0 then
                                Set sourcefldr=fso.getFolder(sourcePATH)
                                                if sourcefldr.files.count > 0 then           
                                                                for each file in sourcefldr.files              
                                                                                fso.MoveFile file, destfolder + "\"                                                                        
                                                                                i=i+1
                                                                                                if i >=200 then                                                                                       
                                                                                                                exit for
                                                                                                end if
                                                                next
                                                end if      

end if

set fso = nothing
set destfolder = nothing
set sourcefolder = nothing

Read & Update Excel file in Selenium

To load and use test data in automation script is a key element in  Automation script execution.  Today we are going to discuss about loading excel files in selenium. There are number of API  are there to support Excel like jExcelAPi, Apache POI.   I found using JDBC connection is the most flexible and method rich option.

How to load excel file in memory:

by giving path of excel file we can load n number of diff excel files to memory for further use:

public void loadExcel(String path) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
this.con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};Dbq=" + path + ";DriverID=790;READONLY=false;");
} catch (Exception e) {
e.printStackTrace();

}
}


How to read full Row in Excel:

You need to give two parameters sheet name and row id. So you can retrieve any row id from given sheet.

public Map<String, String> getRowbyID(String sheet, String id) throws SQLException {
Map<String, String> map = new HashMap<>();
String strQuery = "SELECT * FROM [" + sheet + "$] WHERE [ID]= '" + id + "'";
try {
st = con.createStatement();
resultSet = st.executeQuery(strQuery);
ResultSetMetaData rmd = resultSet.getMetaData();
while (resultSet.next()) {
int columntCount = rmd.getColumnCount();
for (int i = 1; i <= columntCount; i++) {
map.put(rmd.getColumnName(i), resultSet.getString(i));
}
}
} catch (SQLException e) {
e.printStackTrace();
return null;
}
return map;
}

This will return Map having two values one for column and second for value. You can retrieve row value by giving column name.

How to update Excel sheet:

You can write any costume query in the following method and update the appropriate value. Like the following example update the status to yes after given module execution.


public void updateExecutionConfig(String strModuleName, String strTestCategory) throws SQLException {
String strQuery = "update [Sheetname$] set Executed = 'Yes' where ModuleName = '" + strModuleName + "' and TestCategory = '" + strTestCategory + "'";
st = con.createStatement();
int updateRow = st.executeUpdate(strQuery);
System.out.println("updateRow = " + updateRow);
}


These are some examples you can write any costume method appropriate to your selenium framework need.






Download and Upload QTP scripts from Quality Center (QC)

are you tired with QC for storing and downloading QTP scripts?

QC slowness is very common issue and HP should take this on priority.  But till that time lets see how to overcome this QC slowness issue. One way to write an Excel Macro which will take care of uploading and downloading of QTP scripts. Please see how:

1. this is Excel where you need to provide appropriate details:




 2. When you click on download scripts button the macro will download all qtp test scripts from given node to given shared folder path. the same way when you click on Upload scripts the macro will  upload all scripts from shared folder path to QC.


------------------------------------------------------------------------------------------------------------------------------

See what happen when user click on download scripts or upload scripts buttons


Sub cmdDownloadScripts_Click()

'Confirm Download
Dim Response As VbMsgBoxResult
Response = Msgbox("Confirmation: Download Scripts from QC?", vbQuestion + vbYesNo)
If Response = vbNo Then
    Msgbox "Download Canceled."
    Exit Sub
End If

'Confirm Attachment Download
Dim ResponseA As VbMsgBoxResult
ResponseA = Msgbox("Confirmation: Download Scripts with Attachments?", vbQuestion + vbYesNo)
If ResponseA = vbYes Then
    iReplyA = "Yes"
Else
    iReplyA = "No"
    Msgbox "Download Attachments Cancelled."
    'Exit Sub
End If

'Clear Results and Values
    RowCount = ThisWorkbook.Worksheets("Scripts").UsedRange.Rows.Count
    If RowCount > 13 Then
    ThisWorkbook.Worksheets("Scripts").Range("A14", "A" & RowCount).Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Selection.EntireRow.Delete
    ThisWorkbook.Save
    End If

strQualityCenterURL = Trim(Sheets("Scripts").Range("B2").Value)
strDomain = Trim(Sheets("Scripts").Range("B5").Value)
strProject = Trim(Sheets("Scripts").Range("B6").Value)
strUserName = Trim(Sheets("Scripts").Range("B3").Value)
strPassword = Trim(Sheets("Scripts").Range("B4").Value)
strTestPlanProjectPath = Trim(Sheets("Scripts").Range("B8").Value)
strSharedFolderPath = Trim(Sheets("Scripts").Range("B9").Value)

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim tdc
Dim ModuleName

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible

' Connect to the Quality Center
If Not qtApp.TDConnection.IsConnected Then
    qtApp.TDConnection.Connect strQualityCenterURL, strDomain, strProject, strUserName, strPassword, False
End If

If qtApp.TDConnection.IsConnected Then ' If connection is successful

    Set tdc = qtApp.TDConnection.TDOTA
    Set TreeMgr = tdc.TreeManager
   
    ' Use TreeManager.RootList to get the Subject root.
    Set Trees = TreeMgr.RootList(TDOLE_SUBJECT)
    Set MyTrees = TreeMgr.NodeByPath(strTestPlanProjectPath)
   
    If MyTrees.Count = 0 Then
        ModuleName = ""
        testPath = MyTrees.Path
        strFSPath = strSharedFolderPath
        Call CreateFolder(strFSPath)
        If iReplyA = "Yes" Then
            strFSAPath = strFSPath & "\" & Trim(ModuleName) & " Attachments\"
            Call CreateFolder(strFSAPath)
        End If
        Call DownloadScripts(qtApp, tdc, testPath, strFSPath, ModuleName)
        If iReplyA = "Yes" Then
            Call DownloadAttachements(qtApp, tdc, testPath, strFSAPath)
        End If
    End If

   Call CreateFolder(strSharedFolderPath)
  
   For iChild = 1 To MyTrees.Count
        ModuleName = Trim(MyTrees.Child(iChild).Name)
        strFSPath = strSharedFolderPath & "\" & ModuleName
        Call CreateFolder(strFSPath)
        If iReplyA = "Yes" Then
             strFSAPath = strFSPath & "\" & ModuleName & " Attachments\"
            Call CreateFolder(strFSAPath)
        End If
        Set Locate = MyTrees.FindChildNode(ModuleName)
        testPath = Locate.Path
        Call DownloadScripts(qtApp, tdc, testPath, strFSPath, ModuleName)
        If iReplyA = "Yes" Then
            Call DownloadAttachements(qtApp, tdc, testPath, strFSAPath)
        End If
    Next
   
qtApp.TDConnection.Disconnect ' Disconnect from Quality Center

Else
    Msgbox "Cannot connect to Quality Center" ' If connection is not successful, display an error message.
End If

' Exit QuickTest
qtApp.Quit

' Release the Application object
Set qtApp = Nothing
Set Locate = Nothing
Set MyTrees = Nothing
Set Trees = Nothing
Set TreeMgr = Nothing
Set tdc = Nothing

Msgbox "Download Process is completed"

End Sub
Function WriteScriptNames(strFSPath, strScriptName, ModuleName, resFlag)

    iRow = Sheets("Scripts").UsedRange.Rows.Count + 1
    Sheets("Scripts").Range("A" & iRow).Value = strFSPath
    Sheets("Scripts").Range("B" & iRow).Value = strScriptName
    Sheets("Scripts").Range("D" & iRow).Value = ModuleName
    Sheets("Scripts").Range("E" & iRow).Value = resFlag
   
End Function
Function CreateFolder(strFolderPath)

   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")

   If Not (fso.FolderExists(strFolderPath)) Then
        Set f = fso.CreateFolder(strFolderPath)
        Set f = Nothing
   End If

   Set fso = Nothing
  
End Function

Function DownloadScripts(qtApp, tdc, testPath, strFSPath, ModuleName)

    For Each oTestSet In tdc.TreeManager.NodeByPath(testPath).TestFactory.NewList("")
           
            ScriptName = oTestSet.Name
            Script = "[QualityCenter] " & testPath & "\" & ScriptName
            ScriptFSScript = strFSPath & "\" & ScriptName
           
            resFlag = ""
            Flag = False
            On Error Resume Next
            qtApp.Open Script, False ' Open the test
            If Err.Number <> 0 Then
            Flag = True
            End If
            qtApp.Test.SaveAs ScriptFSScript
            If Err.Number <> 0 Then
            Flag = True
            Else
            qtApp.Test.Close
            End If
           
            If Flag = True Then
                resFlag = "Error: " & Err.Description
                Flag = False
                Err.Clear
            Else
                resFlag = "Pass"
            End If
            Call WriteScriptNames(strFSPath, ScriptName, ModuleName, resFlag)
           
            resFlag = ""
Next
End Function
Function DownloadAttachements(qtApp, tdc, testPath, strFSAPath)

    For Each oTestSet In tdc.TreeManager.NodeByPath(testPath).TestFactory.NewList("")
            ScriptName = oTestSet.Name
            Script = "[QualityCenter] " & testPath & "\" & ScriptName
            Dim otaAttachmentFactory
            Dim otaAttachment 'As TDAPIOLELib.Attachment
            Dim otaAttachmentList 'As List,
            Dim TAttach 'As Attachment 'As TDAPIOLELib.List
            Dim otaTreeManager 'As TDAPIOLELib.TreeManager
            Dim otaSysTreeNode 'As TDAPIOLELib.SysTreeNode
            Dim otaExtendedStorage, AttachDow
            Dim fso
           
            Set fso = CreateObject("Scripting.FileSystemObject")
            Set otaAttachmentFactory = oTestSet.Attachments
            Set otaAttachmentList = otaAttachmentFactory.NewList("")
            'MsgBox "Attachment Count:" & otaAttachmentList.Count
           
            If otaAttachmentList.Count > 0 Then
            Set otaAttachment = otaAttachmentList.Item(1)
            otaAttachment.Load True, ""
            strPath = otaAttachment.Filename
           
                     DownloadAttachements = strPath
                     SysPathF = strFSAPath & "Attachments_" & oTestSet.Name
                     Call CreateFolder(SysPathF)
                     SysPath = SysPathF & "\"
                     Call CreateFolder(SysPath)
                     fso.CopyFile strPath, SysPath
            Else
            'MsgBox "Fail"
            DowloadAttachment = "Empty"
            End If
         
            Set otaAttachmentFactory = Nothing
            Set otaAttachment = Nothing
            Set otaAttachmentList = Nothing
            Set otaTreeManager = Nothing
            Set otaSysTreeNode = Nothing
            Set fso = Nothing

        Next

End Function
Sub cmdUploadScripts_Click()

'Confirm Upload
Dim Response As VbMsgBoxResult
Response = Msgbox("Confirmation: Upload Scripts to QC?", vbQuestion + vbYesNo)
If Response = vbNo Then
    Msgbox "Upload to QC Canceled."
    Exit Sub
End If

'Confirm Attachemnt Upload
Dim ResponseA As VbMsgBoxResult
ResponseA = Msgbox("Confirmation: Upload Scripts with Attachments?", vbQuestion + vbYesNo)
If ResponseA = vbYes Then
    iReplyA = "Yes"
Else
    iReplyA = "No"
    Msgbox "Upload Attachments Cancelled."
    'Exit Sub
End If

Call GenQCUploadPath
strQualityCenterURL = Trim(Sheets("Scripts").Range("C2").Value)
strDomain = Trim(Sheets("Scripts").Range("C5").Value)
strProject = Trim(Sheets("Scripts").Range("C6").Value)
strUserName = Trim(Sheets("Scripts").Range("C3").Value)
strPassword = Trim(Sheets("Scripts").Range("C4").Value)
strTestPlanProjectPath = Trim(Sheets("Scripts").Range("C8").Value)
RowCount = ThisWorkbook.Worksheets("Scripts").UsedRange.Rows.Count
If RowCount > 13 Then
ThisWorkbook.Worksheets("Scripts").Range("F14", "F" & RowCount).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Delete Shift:=xlUp
ThisWorkbook.Save
End If

'Get the Paths from Worksheet
strQualityCenterURL = Trim(Sheets("Scripts").Range("C2").Value)
strDomain = Trim(Sheets("Scripts").Range("C5").Value)
strProject = Trim(Sheets("Scripts").Range("C6").Value)
strUserName = Trim(Sheets("Scripts").Range("C3").Value)
strPassword = Trim(Sheets("Scripts").Range("C4").Value)
strTestPlanProjectPath = Trim(Sheets("Scripts").Range("C8").Value)
strSharedFolderPath = Trim(Sheets("Scripts").Range("C9").Value)

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim tdc
Dim ModuleName

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
Set tdc = qtApp.TDConnection.TDOTA
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible

' Connect to the Quality Center
If Not qtApp.TDConnection.IsConnected Then
    qtApp.TDConnection.Connect strQualityCenterURL, strDomain, strProject, strUserName, strPassword, False
End If

If qtApp.TDConnection.IsConnected Then ' If connection is successful
       
        iMaxRow = Sheets("Scripts").UsedRange.Rows.Count
        Set tdc = qtApp.TDConnection.TDOTA
        For iRow = 14 To iMaxRow
            strQCPath = Trim(Sheets("Scripts").Range("C" & iRow).Value)
            strScriptName = Trim(Sheets("Scripts").Range("B" & iRow).Value)
            strFSFolder = Trim(Sheets("Scripts").Range("A" & iRow).Value)
           
            Call UploadScripts(qtApp, strScriptName, strQCPath, strFSFolder, iRow)
            If iReplyA = "Yes" Then
                strFSAPath = Trim(Sheets("Scripts").Range("A" & iRow).Value) & "\" & Trim(Sheets("Scripts").Range("D" & iRow).Value) & " Attachments\"
                Call UploadAttachments(tdc, strScriptName, strQCPath, strFSAPath)
            End If
           
        Next
       
qtApp.TDConnection.Disconnect ' Disconnect from Quality Center
Else
    Msgbox "Cannot connect to Quality Center" ' If connection is not successful, display an error message.
End If

qtApp.Quit ' Exit QuickTest

Set qtApp = Nothing ' Release the Application object
Set Locate = Nothing
Set MyTrees = Nothing
Set Trees = Nothing
Set TreeMgr = Nothing
Set tdc = Nothing

Msgbox "Process is completed"
End Sub

Function UploadScripts(qtApp, ScriptName, strQCPath, strFSPath, iRow)
           
            QCScript = "[QualityCenter] " & strQCPath & "\" & ScriptName
            ScriptFSScript = strFSPath & "\" & ScriptName
            Flag = False

            On Error Resume Next
            qtApp.Open ScriptFSScript, False    ' Open the test
           
            If Err.Number <> 0 Then
                Flag = True
            Else
                qtApp.Test.SaveAs QCScript      ' Save it to Quality
            End If
           
            If Err.Number <> 0 Then
                Flag = True
            Else
                qtApp.Test.Close                ' Disconnect from Quality Cente
            End If
           
            If Flag = True Then
                Sheets("Scripts").Range("F" & iRow).Value = "Error: " & Err.Description
                Flag = False
                Err.Clear
            Else
                Sheets("Scripts").Range("F" & iRow).Value = "Pass"
            End If
           
End Function
'Sub Call1()
 'Call GenQCUploadPath
'End Sub
Function GenQCUploadPath()

iMaxRow = Sheets("Scripts").UsedRange.Rows.Count
For nrow = 14 To iMaxRow
If Trim(Sheets("Scripts").Range("D" & nrow).Value) <> "" Then
    Sheets("Scripts").Range("C" & nrow).Value = Sheets("Scripts").Range("C8").Value & "\" & Sheets("Scripts").Range("D" & nrow).Value
Else
    Sheets("Scripts").Range("C" & nrow).Value = Sheets("Scripts").Range("C8").Value
End If
Next

End Function

Function UploadAttachments(tdc, ScriptName, testPath, strFSAPath)
 
  Flag = 0
  On Error Resume Next
  For Each oTestSet In tdc.TreeManager.NodeByPath(testPath).TestFactory.NewList("")
       
       ScriptName = oTestSet.Name
       If ScriptName = oTestSet.Name And Flag = 0 Then
       
       Flag = 1
       
       Script = "[QualityCenter] " & testPath & "\" & ScriptName
       strFSAPath = strFSAPath & "Attachments_" & ScriptName
       
       Dim otaAttachmentFactory
       Dim otaAttachment
       Dim otaAttachmentList
       Dim fso, oFolder, oFile, ExStrg
       
       Set fso = CreateObject("Scripting.FileSystemObject")
       Set oFolder = fso.GetFolder(strFSAPath)
      
       If Err.Description = "Path not found" Then
            'Msgbox "Test Not found on filesystem. Note the Error. Err.Description:" & Err.Description
            nrow = Worksheets("Sheet2").UsedRange.Rows.Count
            Sheet2.Cells(nrow + 1, 1) = Err.Description & " for " & ScriptName
       End If
      
       'Pending: Check If the folder Exists; If not exit the loop iteration
       Set oFile = fso.GetFolder(strFSAPath).Files
      
       On Error Resume Next
       For Each oFile In oFolder.Files
            Filename = oFile.Name
            Set otaAttachmentFactory = oTestSet.Attachments
            Set otaAttachment = otaAttachmentFactory.AddItem(Filename)
            Filename = strFSAPath & Filename
            otaAttachment.Filename = Filename
            otaAttachment.Post
            Set ExStrg = otaAttachment.AttachmentStorage
            ExStrg.ClientPath = Script
            ExStrg.Save Filename, True
       Next
                    
       'Clear
       Set otaAttachmentFactory = Nothing
       Set otaAttachment = Nothing
       Set otaAttachmentList = Nothing
       Set fso = Nothing
       Set ExStrg = Nothing
       
       End If
    Next

End Function

Extract Defects in Excel from QC

Sharing the function to extract defects in Excel from QC. Need to change the following things specific to your project in the excel sheet

QC - URL
QC - Username and password
QC - Domain and project for which you need defects

You can filter defcts by proding search criteria







To this Excel macro click on ExtractDefects button.
----------------------------------------------------------------------------------------------------------------------------
Sub DefectsExtract()

Dim qcServer As String
qcServer = "http://qc.prod.internal.****.co.uk:8080/qcbin"
 
Dim QCConnection
Set QCConnection = CreateObject("TDApiOle80.TDConnection")


  QCConnection.InitConnectionEx qcServer
  QCConnection.Login "username", "password"
  QCConnection.Connect "Domain", "Project"
 
 
Dim Bug, Row
Dim i As Integer
Dim k As Integer

' Get a list of all the defects.

Dim BugFactory, BugList, bugfilter
Set BugFactory = QCConnection.BugFactory
Set bugfilter = BugFactory.Filter


bugfilter.Filter("BG_USER_03") = "Web" ' Filter the defects based on the stream value
bugfilter.Filter("BG_DETECTION_DATE") = ">01/03/2010"
Set bglist = bugfilter.NewList     
        ActiveSheet.Range("A1:O3000").ClearContents
        Row = 1
        Sheet2.Cells(Row, 1) = "Total No. of Defect with Status : " & bglist.Count
        Row = 2
        ' Heading for the Columns
        Sheet2.Cells(Row, 1).Value = "Defect_ID"
        Sheet2.Cells(Row, 2).Value = "Defect Summary"
        Sheet2.Cells(Row, 3).Value = "DetectedBy"
        Sheet2.Cells(Row, 4).Value = "Priority"
        Sheet2.Cells(Row, 5).Value = "Status"
        Sheet2.Cells(Row, 6).Value = "AssignedTo"
        Sheet2.Cells(Row, 7).Value = "Stream"

     For Each Bug In bglist      ' Save a specified set of fields.
               
                'For j = 0 To bglist.Count
                Row = Row + 1
                Sheet2.Cells(Row, 1).Value = Bug.Field("BG_BUG_ID")
                Sheet2.Cells(Row, 2).Value = Bug.Summary
                Sheet2.Cells(Row, 3).Value = Bug.DetectedBy
                Sheet2.Cells(Row, 4).Value = Bug.Priority
                Sheet2.Cells(Row, 5).Value = Bug.Status
                Sheet2.Cells(Row, 6).Value = Bug.AssignedTo
                Sheet2.Cells(Row, 7).Value = Bug.Field("BG_USER_03")
                'Next j
            Next

End Sub

Selenium - click on override link IE

How to get rid of SSL security certificatee page in IE

Simply use the following line before entering login information.

driver.navigate().to("javascript:document.getElementById('overridelink').click();

Here we are using java script to click on overridelink.