Results 1 to 3 of 3

Thread: Searching a string in a page

  1. #1
    Geek_Guest
    Guest

    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


  2. #2
    Expert Member
    Join Date
    Apr 2008
    Answers
    1,859

    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


  3. #3
    Junior Member
    Join Date
    Apr 2009
    Answers
    25

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact