How to identify buttons

Queries related to T-Plan Robot
Post Reply
cheryle.gannaway.ext
User
User
Posts: 2
Joined: Thu Oct 07, 2010 2:39 pm
First Name: Cheryle
Last Name: Gannaway
Company: Siemens

How to identify buttons

Post by cheryle.gannaway.ext » Thu Oct 07, 2010 7:09 pm

Question: Is there a good way of identifying buttons within an application such that the test script could just be instructed to "Press Print"
?

thanks

rpes
User
User
Posts: 74
Joined: Thu Oct 29, 2009 5:43 pm
First Name: Robert
Last Name: Pes
Company: T-Plan

Re: How to identify buttons

Post by rpes » Fri Oct 08, 2010 12:21 pm

Since Robot is image based testing tool, it doesn't have visibility of the application component tree and it can not locate components (buttons, drop downs, text fields etc.) by the name or the text they display. Instead of that it employs image comparison to locate components based on presaved template images.

A theoretical option is to use OCR to locate the text on the screen; the free Tesseract OCR engine which is integrated with Robot 2.2 is however not suitable for this task. This would improve with support of another more advanced OCR such as for example ABBYY.

You may create your own routine which will perform the task of searching and clicking. The "Print" text in your example however must refer to a template image rather than to a component text or label. The following example demonstrates a simple procedure which combines the image search and mouse click actions. Note that you may not use "Press" as the procedure name because it is already reserved by the language:

Code: Select all

# Find a component and click it.
# Parameters:
# {1} - Name of the folder with component image(s) in the template path
procedure click {
  Compareto "{1}" method="search"
  if ({_EXIT_CODE} == 0) {
    Mouse click to=x:{_COMPARETO_CLICK_X},y:{_COMPARETO_CLICK_Y}
  } else {
    Exit 1
  }
}
If you have a template image of the Print button saved under the Print/ folder in the specified template path (image folder), you may simply call:

Code: Select all

click Print

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest