-
Searching a string in a page
This is my pseudo code-
In QTP - I am searching a string in a page (comparing with my defined array). The string may be anywhere of the page.
Can anyone please give the code.
Thanks
Sudip Ray
Question asked by visitor Sudip Ray
-
Expert Member
Re: Searching a string in a page
Hai friend, here is the sample code, please change as per your requirement for p = 1 to .paragraphs.count
startrange = .paragraphs(p).range.start
endrange = .paragraphs(p).range.end
set trange = .range(startrange, endrange)
‘ tstring = trange.text
trange.find.text = searchstring
trange.find.execute if trange.find.found then
msgbox “yes! ” & searchstring & ” is present”
end if
next thanks
deepa
-
Junior Member
Re: Searching a string in a page
Hi
QTP has a method "GetVisibleText" to get the text from the specified area.
ex: abc = Browser("bname").Page("pname").GetVisibleText
now check the "abc" value with the string which you are searching using the INSTR....
for example,
SearchString = "Search"
abc = Browser("bname").Page("pname").GetVisibleText
If Instr(abc,SearchString) then
Msgbox " String Found"
else
Msgbox "String not Found"
End if
Try with the above code with proper application data...
MANI
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules