image recognition fails

Why does my image recognition fail at times?
Care has been taken while capturing the image and saving as text type ,since some truncation happens..
I've recoreded the text imagesa and set the image type as text.
The script runs for few iterations but cannot find image after few iterations.
Is our image recognition algo has someting to do with it?
What is the work around?


  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Eggplant's image recognition is extremely reliable. When it fails to find an image it's almost always for one of two fundamental reasons. Either:
      1. the object on screen looks different from the image you captured (sometimes in very subtle ways); or 2. the object didn't appear on the screen until after Eggplant stopped looking for it. [/list:u]
    Identify the Problem
    To determine which of these is the cause of your script failure, do this:

    When your script fails because an image was not found, and it appears to you that the image should have matched, make Eggplant look again. Usually the simplest way to do this is to select the command in your script that failed to find the image (whether it's a Click command, or WaitFor, or whatever) and use Run Selection to run just that one command again.

    If your script is more complex and that approach won't work, you can enter a command in the Ad-Hoc Do Box (at the bottom of the Run window) to cause Eggplant to look for the image, such as MoveTo "yourImageName".

    If the command still fails to find the image then you have case 1 above (something looks different). If it succeeds, that means that Eggplant was now able to find the image, so it is almost certainly a timing problem.

    1. Solutions to Problem of Different Images
    If the object on the screen looks different than when it was first captured, there are a few possible remedies.
      (A) If the image contains text, it's likely that the problem is caused by the way text is displayed by the system (this is particularly common on Mac OS X, which draws text differently almost every time it is shown). In this case, set the image's search type to "Text" (select the image in the Images tab of the Suite window, click the "Info" button to open the drawer and choose "Text" from the Search Type popup). You can then run the failed command once more to see if that solves the problem. Another factor to keep in mind is that the settings on the SUT that control "font smoothing" or other text characteristics should not be changed. (B) If the image doesn't contain text, then something else is different about the image on screen. Make sure that your captured image does not include any transient elements such as a blinking insertion point, cursor, or focus ring. Ideally, your image should only include the minimum amount needed to uniquely identify the desired object on the screen. (C) Sometimes an object has two or more "states" (on/off, selected/unselected, etc.) that are each displayed with a different look. In this case you can capture multiple images of the same object (give each image a different name) and use one of the "Any..." commands (ClickAny, WaitForAny, etc.) to tell Eggplant to look for any of those images. [/list:u]
    2. Solutions to Timing Problems
    If Eggplant fails to find an image during a script run, but is able to find it after the failure, this indicates a timing problem. Timing problems are sometimes subtle and hard to recognize as such, but they are the most common cause of apparently inconsistent script behavior. Again, there are a number of possible solutions.
      (A) Often, script failures occur after an action that requires the SUT to do some work, such as launching an application, opening a window, etc. In these cases, it is a good idea to add a WaitFor command to tell Eggplant to be patient and wait for the SUT to do its work. (B) Depending on what your script is doing at the point of failure, you might choose to use the ImageFound() function rather than a WaitFor command. The ImageFound() function can take an optional time parameter to specify how long it should wait in looking for an image. In some rare situations, a plain Wait command (e.g., "Wait 20 seconds") may be needed, but usually there is some visual cue that your script can use to determine when to proceed. (C) If you find that you need to insert WaitFor commands frequently in your script (such as when working with a slower SUT or a web-based application that requires longer delays before many actions) you may want to just slow Eggplant down altogether. In this case, change the RemoteWorkInterval to a higher number, either by setting it in your preferences (Eggplant -> Preferences... -> Run Options -> System) or by setting it in your script (e.g., "set the remoteWorkInterval to 1.1"). This can simplify your scripting in cases where it's called for. [/list:u]
    3. Documentation
    Be sure to read more about this and other topics in the Using Eggplant manual and other documentation (available from Eggplant's Help menu). A lot of valuable information is included there that may be of help.

    4. Support
    If none of these options resolve the issue, and you've read the documentation and searched the forums without success, contact Redstone's support staff (support at redstonesoftware dot com) for assistance. We're always happy to help resolve those challenging cases!
  • Hi,
    Whenever there is a Java Warning coming up,image recognition is failing.
    It happens in Windows and Linux where as in Mac, as you mentioned that fonts might be different at times,image recongnition is not failing.I've tried all the methods mention in your previous posts.
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    If a Java Warning panel is anticipated at some point in your script (that is, you expect that one might pop up after a particular action) then your script should probably check for it at that point and deal with it appropriately (log an error, abort the script, dismiss the warning, or whatever).

    If, on the other hand, the Java Warning may pop up unexpectedly at any of a number of points in the script, and is disrupting your test, then there are a couple of possibilities. It may be that these popups indicate a problem with your application (i.e., you don't want your users to experience these warnings). In this case, your script has found a defect in the software (that's why you test, right?). But you may want to log an error and continue with the rest of your test. Or you may not consider these warnings to be a problem and want your script to dismiss them and continue the test.

    In either of these cases, you may be able to make use of Eggplant's built-in Omega13 script to allow your script to attempt to recover from the unexpected event (such as by dismissing the warning) so that it can go on. To find out more about this capability, type "Omega13" in the Ad-Hoc Do Box at the bottom of the Run window in Eggplant and it will explain how to write an attemptRecovery script in order to use this feature.

    (NOTE: The Omega13 script was inadvertently omitted from the original version of Eggplant 2.22 that was downloadable from our website, so if typing Omega13 gives you an error message, you may need to download and install the latest Eggplant package for this to work. The current package includes this script.)

    The Omega13 script was created to allow your scripts the opportunity to recover in situations where windows may pop up unexpectedly and block Eggplant from seeing and interacting with the application it is driving. It may not help in all situations, but it may also have other uses. By supplying a minimal attemptRecovery script like this one:
    (* attemptRecovery.script *)
    pauseScript -- allow manual intervention
    return YES
    your script will pause whenever an image is not found. This will allow you to intervene directly with the SUT through Live Mode to manually correct any problems. Clicking the "Continue" button in the Run window's toolbar will then retry the failed operation and resume your script.
  • Hi

    when we capture images,then there are four options in the Search Type ( Precise , Tolerant , Pulsing , Text and Text & Pulsing) .

    1. What are there significance specfic to image capturing

    2. if there is a text on image ( button) . Can I capture it always with "Text".

    On most of occasions I faced image recosignation fails second time , when I select Tolerant or pulsing .

    3. Is always capturing the image with text is safe method( where text does not change)
  • Some images may require a specific search type when it comes time for Eggplant to search for the image on your remote screen. Most of the time Eggplant will attempt to select the appropriate search type for the images that you capture.

    The text search type is a search type that you have to select manually. This search type is mainly applicable to text that is dynamically antialiased. OS X for example, is known for dynamically antialiasing text. Antialiased text on other platforms, such as Windows, are more likely to be statically antialiased. So a tolerant search type for those platforms should suffice. If you are capturing text images on OS X however, it is recommended that you always select the text search type. It is also recommended that you use a standard font smoothing setting on the platforms that you test against. The text search type was designed specifically for captured text images on OS X. It was not designed to circumvent different settings for font smoothing.

    For a full description on the various search types consult the "Using Eggplant" manual, page 15. For additional information related to search type consult page 129 on Precise Image Tolerance and Standard Image Tolerance.
  • gstarkgstark Member
    I am seeing a consistent failure, with a specific set of text.

    The actual text string is generated and stored, and may vary between a number of organisational names. I have a counter and append the value of that counter to the end of the organisation name.

    That value is retained an used within the then current iteration of the script.

    I then use TIG to generate an image against which I can locate the item in a treeview after the item has been created and added to the database in the SUT.

    For most of those organisations, this text image, as created by the TIG, locates the appropriate item on the treeview, and the script proceeds.

    However, I occasionally see an error, and when I do, it invariably contains the one text string, "Raine & Horne". It's as though there is something actually wrong with the way that the "Raine & Horne" text string actually gets rendered within the TIG, or else how the representation of that specific string is rendered in the treeview.

    As you can see, the item exists in the treeview, and none of the other treeview items shown here experienced any such issues.

    Any thoughts on this?
    why.tiff 608.5K
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    The Windows TIG has the ability to underline an individual character within the generated text image, which is useful for matching menu items that indicate the control-key equivalent by underlining that character. The mechanism to do this is to precede the underlined character with an ampersand (&).

    Beginning with Eggplant 4.1, we've provided mechanisms to give you some control over this and some other markup capabilities in the various TIGs, using a useMarkup property, and the defaultUseMarkup global property. If you're running 4.1 or later, make sure that either the defaultUseMarkup is turned off, or that you include useMarkup:NO as one of your text properties.

    If you are using an earlier version of Eggplant, the way to generate an actual "&" character is to send "&&" to the TIG. So you might do something like this:
    set textToClick to "Raine & Horne"
    replace "&" with "&&" in textToClick
    click (text:textToClick)

    Hopefully one of these approaches will get your script working. Search the documentation and the release notes for more information on text markup in generated text.
  • Hi,

    I got similar problem to mentioned above I think. Trying to click a button on web site but it has some CSS properties that makes it inverted colors on mouse over (background color becomes color of font and vice versa).
    At the beginning I've been trying simply to click the image of button, after that clicking on ImageLocation+(5,5). Today I tried putting image location into variable and click just the pair of (x,y) from that. Nothing happens even that console shows everytime, that buttonImage is found at (someX, someY) and click at this point.

    Any suggestions how to work it around?

    Edit: if I set a beakpoint on line with Click "imageName" and click to continue script execution while it stops on breakpoint click action is done without any problems. This is really strange to me.
  • JonathanOSXJonathanOSX ForumAdmin admin
    That seems like a different problem, not that the image isn't found.

    By default Eggplant jumps the mouse to the desired location. For some UI frameworks that behavior doesn't work. So I think the solutions is to have your mouse move more slowly to the target. You can do that within your script by setting the mouseMoveSpeed like so:
    set the mouseMoveSpeed to 5
    click "MyImage"
    set the mouseMoveSpeed to 0 -- go back to jumping
  • vkazavkaza Member

    I am trying to click a flash image. (This has animation for 15 seconds and finally stays on some image after end of animation. I am capturing this final image for capture and waiting for it.) The script is always failing to find the image after waiting for 15 seconds. The same script works fine if it needs to find a standard image that is found and clicked. However, my test scenario requires it to be executed on standard images and next test case when there is flash image after animation for 15 seconds.

    Any reasons why this may be failing ?

  • I have code for windows xp. but this same code will work on Windows 7 also..The problem is the popups of xp and win7 are different. So how can I groping this images.

    Please tell me how the images groping in capturing Images.
Sign In or Register to comment.