Sometimes it is difficult to verify webelements text if their properties change dynamically, in these situations the other way round is to verify whether the expected message is displayed on the page or not.
Code:
Set oPage = Browser().Page()
Set oDescWebElement = Description.Create
oDescWebEement("micclass").value = "WebElement"
oDescWebElement("visible").value = True
bFndFlag = False
Set colWebElements = oPage.ChildObjects(oDescWebElement)
For iCnt=0 to colWebElements.Count-1 Step 1
If colWebElements(iCnt).GetROProperty("outertext") = "Expected Text" Then ' use Instr if specific text needs to be checked
bFndFlag = True
Exit For
End If
Next
If bFndFlag = True Then
Print "passed: text found on the page"
Else
Print "failed: text not found on the page"
End If
An alternative way would be to capture the text as displayed in Page source using msxml object. For details on msxml object refer book ' Test automation and qtp - excel with ease'
Sometimes it is difficult to verify webelements text if their properties change dynamically, in these situations the other way round is to verify whether the expected message is displayed on the page or not.
Code:
Set oPage = Browser().Page()
Set oDescWebElement = Description.Create
oDescWebEement("micclass").value = "WebElement"
oDescWebElement("visible").value = True
bFndFlag = False
Set colWebElements = oPage.ChildObjects(oDescWebElement)
For iCnt=0 to colWebElements.Count-1 Step 1
If colWebElements(iCnt).GetROProperty("outertext") = "Expected Text" Then ' use Instr if specific text needs to be checked
bFndFlag = True
Exit For
End If
Next
If bFndFlag = True Then
Print "passed: text found on the page"
Else
Print "failed: text not found on the page"
End If
An alternative way would be to capture the text as displayed in Page source using msxml object. For details on msxml object refer book ' Test automation and qtp - excel with ease'
Sometimes it is difficult to verify webelements text if their properties change dynamically, in these situations the other way round is to verify whether the expected message is displayed on the page or not.
Set oPage = Browser().Page()
Code:
Set oDescWebElement = Description.Create
oDescWebEement("micclass").value = "WebElement"
oDescWebElement("visible").value = True
bFndFlag = False
Set colWebElements = oPage.ChildObjects(oDescWebElement)
For iCnt=0 to colWebElements.Count-1 Step 1
If colWebElements(iCnt).GetROProperty("outertext") = "Expected Text" Then ' use Instr if specific text needs to be checked
bFndFlag = True
Exit For
End If
Next
If bFndFlag = True Then
Print "passed: text found on the page"
Else
Print "failed: text not found on the page"
End If
An alternative way would be to capture the text as displayed in Page source using msxml object. For details on msxml object refer book ' Test automation and qtp - excel with ease'