Forum Discussion

MVenkataraman's avatar
MVenkataraman
Occasional Contributor
12 years ago

How to get the text from the application and compare it to previously known text

Hi:



I am trying to read the text from a message box(popup box which prompts a hit, miss or abort message) each time it appears. The text can be either "Hit", "Miss" or "Abort". I need to find which message it is and count the number of occurances each event occurs during the execution of the script and write the count to a text file.



I am finding it hard to figure out what text the message box has. How do i find this out?



Thanks,

Madhan
  • I don't recommend TC's OCR at all, result of recognition sometimes unpredictable and can provoke false negatives. I played with OCR couple of years ago and gave up.



    How do you track the event when message appears? Is it an onscreen object which TC can detect? If so, have you tried to inspect properties and find one which contains the text you need?



    I just want to make sure that image processing is only solution.



  • I don't recommend TC's OCR at all, result of recognition sometimes unpredictable and can provoke false negatives. I played with OCR couple of years ago and gave up.



    How do you track the event when message appears? Is it an onscreen object which TC can detect? If so, have you tried to inspect properties and find one which contains the text you need?



    I just want to make sure that image processing is only solution.



  • Hi Madhan -

    If you are using keyword tests, you can do something like this:   



    If (object property that shows the text) equals (constant/string/Miss) Then

      Set Variable Value  Missvariable  Missvariable + 1

    Else

       If (object property that shows the text) equals (constant/string/Hit) Then

          Set Variable Value  Hitvariable  Hitvariable + 1

       Else

             If (object property that shows the text) equals (constant/string/Abort) Then

                    Set Variable Value  Abortvariable  Abortvariable + 1

             Else

                   log an error  



    The wizard for If/Then will walk you through picking the values.  











  • MVenkataraman's avatar
    MVenkataraman
    Occasional Contributor
    If anyone needs more info regarding this from me, do let me know. I am using vbscript and have researched using Text Recognition feature of TestComplete. But i am not able to implement it correctly.



    Thanks in advance!!

    Madhan
  • MVenkataraman's avatar
    MVenkataraman
    Occasional Contributor

    Hi Andrey:


     


    Thanks for your reply!


     


    Yes this is an onscreen message and i used object Spy to inspect properties.



    The "MappedName" is "Aliases.SysApp.wndMessageBoxClass.Static"



    and "WndCaption" property is "Hit" or "Miss" or "Abort". I am trying to use the WndCaption property to differentiate between them but being new to this i am not able to get a way to use this property.



    Regards,

    Madhan

  • MVenkataraman's avatar
    MVenkataraman
    Occasional Contributor
    I am not using Keyword test. I am writing scripts. In that case would it be different?



    Thanks,

    Madhan
  • You could use the same design in a script, but I don't know the syntax, sorry.  
  • MVenkataraman's avatar
    MVenkataraman
    Occasional Contributor
    Thanks Marsha:



    Atleast i got the idea. Thank you for your help.



    Regards,

    Madhan