Select Page

Category Selected: 2016

52 results Found


People also read

Accessibility Testing

Cypress Accessibility Testing: Tips for Success

Automation Testing

Test Automation Maintenance Costs: Smart Ways to Reduce

Accessibility Testing

Accessibility Testing with Playwright: Expert Guide

Talk to our Experts

Amazing clients who
trust us


poloatto
ABB
polaris
ooredo
stryker
mobility

SeleniumHQ CI

Do you want to use Selenium beta version or to track recent changes as soon as Selenium CI build is done?

You can view all Selenium Jenkinsjobs and download latest Selenium standalone jar from http://ci.seleniumhq.org:8080.

Selenium Jenkins

Latest Selenium standalone jar download

To download latest Selenium standalone jar, select’ Build_All_Java’ job and click selenium-server-standalone-latest.jar link.

Clicking WPF Button

We can automate Windows Presentation Foundation (WPF) applications using QTP with WPF-Addin. But is it possible to automate without addin?

Yes, it is possible. Microsoft launched System.Windows.Automation class with .Net 3.0 Framework. This is also called UI Automation class in .Net. Using this class we can automate WPF applications.We will see how to automate a WPF application using UI Automation class and QTP DOT Net Factory in the forthcoming articles.

First, we start by clicking a WPF button. I have used the below ExpenseIt Standalone WPF application for this implementation.

Expertit Standalone - Clicking WPF Button

 

Code

'WPF_ClickButton function with two arguments
'Argument 1: inWindowHwnd - Window Handle
'Argument 2: strButtonName - Button Name (In this example, the button name is ‘Create Expense Report’)

Function WPF_ClickButton(ByVal inWindowHwnd,ByVal strButtonName)
Dim oTreeScope, oAutomationElement
Dim oInvokePattern, oInptr, oPropertyCondition


'TreeScope object to specify scope of elements
Set oTreeScope=DotNetFactory.CreateInstance("System.Windows.Automation.TreeScope","UIAutomationTypes")

'AutomationElement object is used to retrieve the element
Set oAutomationElement=DotNetFactory.CreateInstance("System.Windows.Automation.AutomationElement","UIAutomationClient")

'PropertyCondition object to search the button with Name property, here it takes strButtonName argument as second constructor.
Set oPropertyCondition=DotNetFactory.CreateInstance(" System.Windows.Automation.PropertyCondition","UIAutomationClient",oAutomationElement.NameProperty,strButtonName)

'Since Button control comes under InvokePattern, we need this object to invoke a button.
Set oInvokePattern=DotNetFactory.CreateInstance("System.Windows.Automation.InvokePattern","UIAutomationClient")

'In .Net, Window Handle cannot be taken as Integer or String; it should be passed as IntPtr structure. That is why here inWindowHwnd argument is supplied as constructor for IntPtr object.
Set oInptr=DotNetFactory.CreateInstance("System.IntPtr","",inWindowHwnd)

'Getting the WPF Form using FromHandle method.
Set oAutomationElement=oAutomationElement.FromHandle(oInptr)

'Searching the Button with Name and assigning into oInvokePattern object
Set oInvokePattern=oAutomationElement.FindAll(oTreeScope.Children,oPropertyCondition)(0).GetCurrentPattern(oInvokePattern.Pattern)

'Clicking the button with Invoke button
oInvokePattern.Invoke()

'Killing the objects
Set oTreeScope=Nothing
Set oAutomationElement=Nothing
Set oPropertyCondition=Nothing
Set oInvokePattern=Nothing
Set oInptr=Nothing
End Function

Dim inWindowHandle

'Getting Window handle property using GetRoProperty
inWindowHandle=Window("text:=ExpenseIt Standalone").GetRoProperty("hwnd")

'Call WPF_ClickButton function with Window Handle and Button name
WPF_ClickButton inWindowHandle,"Create Expense Report"
  

Synopsis

From this article you have learnt how to click a WPF button. Using Microsoft UI Automation API, we can automate WPF applications.
 
Note: This implementation can be done from .Net 3.0 Framework onward.

XPath Based QTP Object Identification

XPath object identification is a new feature in QTP 11. We would like to share an example for it using Google web page.

Code

Dim oPage:Set oPage=Browser("name:=Google").Page("title:=Google")

'Entering value in Google textbox
oPage.WebEdit("xpath:=//INPUT[@name='q']").Set "advancedqtp"

'Clicking Google Search button.
oPage.WebButton("xpath:=//INPUT[@value='Google Search']").Click
  

Use WMI Code Creator Tool for Quick WMI Scripting

Are you searching for WMI codes? Or do you want to know about WMI classes and properties?

Microsoft has created an application to reduce our WMI scripting time, it is WMI Code Creator and a free tool from Microsoft. You can download it from the below link,

WMI Scripting

This tool reduces our WMI scripting time. If anyone uses this tool, please include your comments. It may encourage QTP developers to opt this tool for quick WMI scripting.

XPath Examples for QTP Web Objects

XPath Examples for QTP Web Objects

QTP XPath examples to identify web objects. XPath is a language for addressing parts of an XML document. Xpath expressions to select nodes or node-sets in an XML document.

In this blog, we have listed some useful XPath locating techniques for QTP (Automation Testing Tool). If you are a beginner, you can refer this list to improve object locating strategy.

Identifying using ID attribute

obj.WebEdit("xpath:=//input[@id='htmlID']").Set "QTP"  
  

Identifying using Type attribute

'Setting value in first textBox
obj.WebEdit("xpath:=//input[@type='text'][1]").Set "QTP"
  

Identifying using Tagname

'Highlighting first listBox
obj.WebList("xpath:=//select[1]").Select "London"
  

Identifying using Innertext

'Clicking Google link
obj.Link("xpath:=//a[.='Google']").Click
  

Identifying WebTable based on Rowcount

'Highlighting the table which has only two rows
obj.WebTable("xpath:=//table[count(.//tr)=2]").Highlight
  

Retrieve values from Quality Center Test Lab and Defects tab using OTA

Getting the Number of Passed, Failed, No Run and Not Completed Test cases

We can make use of the Filter as given below to get the number of Test cases according to the status Passed, Failed, No Run, Not Completed,etc.

Dim tdc, qcServer
Dim qcUsername,qcPassword,qcDomain,qcProject

Set tdc = CreateObject("TDApiOle80.TDConnection")
qcServer = "QC URL"
tdc.InitConnectionEx qcServer

If tdc.Connected Then
  Msgbox "Connected to QC"
  Else
  MsgBox "Not connected to QC"
End If

qcUsername = "Your QC Username" 'Username
qcPassword = "Your Password"   'Password
tdc.Login qcUsername, qcPassword

If tdc.LoggedIn Then
  MsgBox "Logged in to QC"
  Else
  MsgBox "Logged out from QC"
End If

qcDomain = "Domain" 'QC Domain Name
qcProject = "Project" 'QC Project Name

tdc.Connect qcDomain, qcProject

Dim vPath: vPath="RootAccount1Proj1" 'Path to the folder containing test set
Dim vPass,vFail,vNR,vNC

Dim oTestSet: Set oTestSet = tdc.TestSetTreeManager.NodeByPath(vpath).TestSetFactory.NewList("").Item(1).TsTestFactory 'Item(1) Refers to the 1st test set in the path
Dim testFilter1: Set testFilter1 = oTestSet.Filter

'To Filter by Passed status
testFilter1.Filter("TC_STATUS") = "Passed"
vPass = vPass + oTestSet.NewList(testFilter1.Text).Count

'To Filter by Failed Status
testFilter1.Filter("TC_STATUS") = "Failed"
vFail = vFail + oTestSet.NewList(testFilter1.Text).Count

'To Filter by No Run status
vNR = vNR + oTestSet.NewList("[Filter]{TableName:TESTCYCL,ColumnName:TC_STATUS,LogicalFilter:" & Chr(39) & "No" & Chr(32) & "Run" & Chr(39) & ",VisualFilter:" & Chr(39) & "No" & Chr(32) & "Run" &Chr(39) & ",NO_CASE:}").Count

'To Filter by Not Completed status
vNC = vNC + oTestSet.NewList("[Filter]{TableName:TESTCYCL,ColumnName:TC_STATUS,LogicalFilter:" & Chr(39) & "Not" & Chr(32) & "Completed" & Chr(39) & ",VisualFilter:" & Chr(39) & "Not" & Chr(32) &"Completed" & Chr(39) & ",NO_CASE:}").Count

Msgbox "Passed: "&vPass&" Failed: "&vFail&" No Run: "&vNR&" Not Completed: "&vNC

Set testFilter1=Nothing

Set oTestSet=Nothing

Set tdc=Nothing

  

Getting the Number of Test cases executed by a tester in a specific test set

We can use the below code to get the count of test cases executed by a tester in a particular test set.

Dim vPath: vPath="RootAccount1Proj1" 'Path to the folder containing test set

Dim oTestSet: Set oTestSet = tdc.TestSetTreeManager.NodeByPath(vpath).TestSetFactory.NewList("").Item(1).TsTestFactory 'Item(1) Refers to the 1st test set in the path ; tdc refers to the test
connection object in the previous snippet

Dim testFilter1: Set testFilter1 = oTestSet.Filter
Dim vtestcount: vtestcount=0
Dim tester_name_tester_name="divya" 'QC username of the tester for whom the count has to be calculated
testFilter1.Filter("TC_ACTUAL_TESTER") =chr(34)&Cstr(tester_name)&chr(34)

vtestcount = vtestcount + oTestSet.NewList(testFilter1.Text).Count
Msgbox "Number of Test Cases executed by "&tester_name&" : "&vtestcount
Set testFilter1=Nothing
Set oTestSet=Nothing

  

Getting the number of defects raised by a tester in a specific release according to severity

We need to apply multiple filters as we are using Tester name, Release Name and Defect Severity as the criteria.

Dim Bug_Ct_Bug_Ct=0
Dim tester_name_tester_name="divya"
Dim test_severity_test_severity="2-High"

Dim oBugFactory: Set oBugFactory=tdc.BugFactory
Dim TotBugcnt: TotBugcnt=oBugFactory.NewList("").Count 'To get the total number of defects in Defects tab.
Dim oBugFilter1:Set oBugFilter1=oBugFactory.Filter

oBugFilter1.Filter("BG_DETECTED_BY")=tester_name 'QC username of the tester for whom the defect count has to be calculated
oBugFilter1.Filter("BG_DETECTED_IN_REL") = "^Releasesproj11.1.01.201^" 'Name of the Release
oBugFilter1.Filter("BG_SEVERITY")=test_severity 'Defect Severity. Eg.: Can be 2-High, 1-Critical, 4-Low. Possible Values can be obtained from QC defects tab

Bug_Ct = Bug_Ct + oBugFactory.NewList(oBugFilter1.Text).Count
Msgbox Bug_Ct

Set oBugFilter1=Nothing

  

Getting the number of defects in a specific release according to defect status

Here we need to apply the following criteria: Release Name, Defect status. If we want to be more specific , say, we need to find the same for a particular tester, then we can include tester name as a filter criteria.

The following code will give the output for number of defects raised in a specific release having the status “Closed” which were raised by tester1 and tester2.

Dim Bug_Ct_Bug_Ct=0
Set oBugFactory=tdc.BugFactory
Set oBugFilter1=oBugFactory.Filter
oBugFilter1.Filter("BG_DETECTED_IN_REL") = "^Releasesproj11.1.01.201^" 'Name of the Release
oBugFilter1.Filter("BG_STATUS")="Closed" 'Defect status for which count is calculated
oBugFilter1.Filter("BG_DETECTED_BY")="tester1 or tester2" 'QC Username of the testers for whom the count is calculated
Bug_Ct = Bug_Ct + oBugFactory.NewList(oBugFilter1.Text).Count
Msgbox Bug_Ct
Set oBugFilter1=Nothing
  

Author

Divya Rajaraman