How to read the text of the image

Hi,

My application under test is a chat application, on the same line of MSN Messenger, which allows users to add/delete contact. User can send message to those contacts that are online.

User can open multiple conversation windows and send messages to the contacts.

My scenario is: User opens multiple windows by double clicking on the contacts. Title of the window is after the Contact Name. Out of multiple windows open, I want to type in the message in the specific window. I will take the contact name from the external data file. I would like to know how I can click on the specific window, even if it?s not active window.

Once this is done, I would to get to the different SUT to check message has been communicated property. I would like to verify whether the correct message has been communicated or not. I would like to read the text of the image.


Thanks

MaheshW [/url]

Comments

  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    There are several possible approaches you might use to select a particular chat window. One way, of course, would be to capture images of the title of each window and use those in your script. If that's not practical in your case, you might try cycling through the windows from the keyboard. If your SUT is a Mac, this can be done using Command-Tilde:
    TypeCommand "~"
    
    There may be a similar mechanism for cycling through windows on other operating systems. By typing this command repeatedly the correct number of times you can activate the desired window.

    Another approach that may be more satisfactory although it is slightly more work would be to drag each of your chat windows to a different location on the screen when you first open it. Your script can then record the location for each session window. For example, if you open 4 chat sessions, you could put the window for the first session in the upper left, the second in the upper right, and so forth. Store the window locations in a list and then when you need to activate a particular window your script can click the appropriate location from the list.

    After typing a message in the selected window, use the Connect command to switch to a different SUT. The best way to verify that the correct message was received is to select it in the message window and copy the text to the clipboard. Your script can then use the RemoteClipboard() function to retrieve the copied text from the SUT, and compare the text that was received to the text that was sent. Because SenseTalk ordinarily ignores uppercase/lowercase differences when comparing text, you may want to explicitly specify "considering case" if you need to verify that the text was received exactly.

    Here's an example of how this might all look when it comes together (some of the details will depend on the actual SUTs you are connecting to, etc.):
    -- assume we have the following already:
    --    masterSUT is a property list with connection information for the main SUT
    --    receiverSUT1, receiverSUT2, etc. have connection info for other SUTs
    --    messageToSend has the text we want to send
    --    receiverNumber is set to the number of the chosen receiver (1,2, etc.)
    --    windowLocations is a list of window locations for the chat windows
    
    -- connect to the main SUT
    connect masterSUT
    
    -- activate the window for the receiver we want to send a message to:
    put item receiverNumber of windowLocations into selectedChatWindowLoc
    click selectedChatWindowLoc
    
    -- send the message:
    typeText messageToSend
    typeText return -- (assuming this is how you send the message)
    
    -- switch to the receiver's SUT to see if the message was received:
    -- (we dynamically access the variable name for the connection info using value() )
    connect value("receiverSUT" & receiverNumber) 
    
    -- (assume the receiver's chat window is already the active window)
    typeCommand "A" -- select all text (assuming Mac SUT)
    typeCommand "C" -- copy to clipboard
    
    -- get the received message and compare it to what was sent
    put remoteClipboard() into receivedMessage
    if receivedMessage = messageToSend considering case then
        put "Success" into messageStatus
    else
        put "Failure" into messageStatus
    end if
    

    I hope that's enough to get you started. Let us know if you need additional help making this all work.
Sign In or Register to comment.