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

More Methods For PathFinder

Most of us are aware of the Locate method available for PathFinder object, but there are more useful and unfamiliar methods associated with PathFinder Object. We have listed those methods below,

INSERT

Description:

This method is used to add a new folder path to the Folders list (Tools-> Options-> Folders).

Syntax:

PathFinder.Insert [Path],[Index] 
  

Example:

PathFinder.Insert "C:Test",0  
  

The above example will add new folder path to the Folders list.

FIND

Description:

This method returns the Index of the specified path.

Syntax:

Msgbox PathFinder.Find [Path]
  

Example:

Msgbox PathFinder.Find("C:Test") 
  

It returns the Index of the specified path. If the path is not found, it will return -1.

MOVEITEM

Description:

This method can be used to swap the Index of two folder paths.

Syntax:

Pathfinder.MoveItem [Source_Index],[Destination_Index]
  

Example:

Pathfinder.MoveItem 1,0
  

REMOVE

Description:

This method removes the specified folder path from the folders list.

Syntax:

Pathfinder.Remove [Path]
  

Example:

Pathfinder.Remove("C:Test")
  

REMOVEALL

Description:

This method removes all the items from the folders list.

Example:

Pathfinder.RemoveAll
  

Note: It removes default folder item as well.

REMOVEBYINDEX

Description:

It removes the folder path item using Index.

Syntax:

PathFinder.RemoveByIndex([Path_Index])
  

Example:

PathFinder.RemoveByIndex(0)
  

SAVE

Description:

Save method can be used to commit all the changes which are done using PathFinder object. If Save method is not used, your changes in Folder List will not be retained.

Example:

PathFinder.Save
  

QC Test Lab results update using OTA

Dim tdc, qcServer
Dim qcUsername,qcPassword,qcDomain,qcProject
Dim vPath,oTestSet,oTest,oRunInstance,oRun,oStep,oStepDetails

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

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

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

tdc.Connect qcDomain, qcProject

vPath="RootAutomationScripts" 'Path to the folder contains test sets

'Selecting first Test-Set
Set oTestSet = tdc.TestSetTreeManager.NodeByPath(vpath).TestSetFactory.NewList("").Item(1).TsTestFactory

'Selecting first Test from Testset
Set oTest = oTestSet.NewList("").Item(1)

'Creating a Run
Set oRunInstance = oTest.RunFactory
Set oRun=oRunInstance.AddItem("Automated")'Run Name

oRun.Status = "Passed"'Run Status
oRun.Post   
oRun.Refresh

Set oStep = oRun.StepFactory
oStep.AddItem("Sample Step")'Creating Step
Set oStepDetails = oStep.NewList("")
oStepDetails.Item(1).Field("ST_STATUS") = "PASSED"'Updating Step Status
oStepDetails.Item(1).Field("ST_DESCRIPTION") = "Test Desc"'Updating Step Description
oStepDetails.Item(1).Field("ST_EXPECTED") = "Test Expected"'Updating Expected
oStepDetails.Item(1).Field("ST_ACTUAL") = "Test Actual"'Updating Actual
oStepDetails.Post

Set oStep=Nothing
Set oStepDetails=Nothing
Set oRun=Nothing
Set oRunInstance=Nothing
Set oTest=Nothing
Set oTestSet=Nothing
Set tdc=Nothing
  

SWF Edit Native Properties & Methods

Font Details

Confirming whether textbox’s font is bold or not

Msgbox SwfWindow("Form").SwfEdit("Edit").Object.Font.Bold
'The above line returns true, if the editbox’s font is bold else false.
  

Getting applied font name

Msgbox SwfWindow("Form").SwfEdit("Edit").Object.Font.FontFamily.Name
  

Retrieving Font size

Msgbox SwfWindow("Form").SwfEdit("Edit").Object.Font.Size
  

Text Selection

Selecting all text

SwfWindow("Form").SwfEdit("Edit").Object.SelectAll
  

Selecting a range of text

SwfWindow("Form").SwfEdit("Edit").Object.Select 0,3
'Selects the text from first character to fourth character
  

Retrieving Selected text and starting postion

Msgbox SwfWindow("Form").SwfEdit("Edit").Object.SelectedText
'Gets the selected text

Msgbox SwfWindow("Form").SwfEdit("Edit").Object.SelectionStart
'Gets statring postion of selceted text
  

Appending text

SwfWindow("Form").SwfEdit("Edit").Object.AppendText("QTP")
  

Pasting clipboard value

SwfWindow("Form").SwfEdit("Edit").Object.Paste
  

Line Count

We all know how to count number of lines in a text file. We can use any one of the below methods to do that.

  • Incrementing a counter variable while reading or skipping a line using File System Object (FSO).
  • Read all the content using FSO-ReadAll method, split it line by line and put into an array.
  • Read the content and count no. of lines using RegExp.

But we have one more approach using System.IO.File.ReadAllLines method which is much better and more efficient than the above methods. Let’s see how it is done.

Code

Dim oFile,strFilePath,inLineCount

'Storing File path in strFilePath variable
strFilePath="C:test.txt"

'Creating object for .Net IO File class
Set oFile=DotNetFactory.CreateInstance("System.IO.File","")

'Counting no. of lines using Length after reading all the lines using ReadAllLines method
inLineCount=oFile.ReadAllLines(strFilePath).Length

Set oFile=Nothing
  

Synopsis

If we want to count no. of lines from a text file which is having more number of lines, then we can go for the above method. This method is faster since there is no need to loop line by line using FSO or put all the lines in an array to get the count.

Validating Sorted WebList Values

Validating Sorted WebList. The below code excludes default selected value (i.e. –Choose One–) from validation.

Code

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

arrCtry=Split(oPage.WebList("name:=select1").GetROProperty("all items"),";")
 
Set objArray=DotNetFactory.CreateInstance("System.Collections.ArrayList","")
 
For i=0 to Ubound(arrCtry)
If arrCtry(i)<>"--Choose One--" Then
objArray.Add(arrCtry(i))
End If
Next
 
objArray.Sort()
objArray.Insert 0,"--Choose One--"
 
For j=0 to Ubound(arrCtry)
strOuput=strOuput+objArray(j)
strOuput=strOuput+";"
Next
 
If strOuput=oPage.WebList("name:=select1").GetROProperty("all items")+";" Then
Msgbox "The Weblist's values are sorted in alphabetical order"
Else
Msgbox "The Weblist values are not sorted in alphabetical order"
End If
  

Getting Excel Column Names using ADODB

Getting Excel columns names using ADODB is simpler than Excel COM interface. The below code shows how to retrieve column names from XLS.

Code

strExcelPath="C:Book1.xls"
strTableName="Sheet1$"'Note: $ symbol should be included with Table Name.
Set oCon=CreateObject("ADODB.Connection")

With oCon
.Provider = "MSDASQL"
.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};" & _
"DBQ="&strExcelPath&"; ReadOnly=False;"
.Open
End With

Set oRs1=oCon.OpenSchema(4,Array(Empty, Empty,strTableName,Empty))

Do Until oRS1.EOF
Msgbox oRs1.Fields.Item("COLUMN_NAME").Value
oRS1.MoveNext
Loop

oRs1.Close
oCon.Close

Set oRs1=Nothing
Set oCon=Nothing