Getting the text form a standard tooltip in an HTML document with WinRunner took me some time to figure out. Actually it is one small statement that will do the trick, but finding out what statement kept me searching for a while.
win_get_info("{class: window, MSW_class:\"tooltips_class32\",displayed: 1}","text",text);
This will do it. Really.
And to wrap it into a function:
public function get_tooltip(object, out text)
{
auto hwnd, rc;
# First set the cursor position to the left corner of the screen. When you don't do this,
# a formerly captured tooltip can be hovering over the object, making it impossible
# for WinRunner to locate it.
rc = move_locator_abs(1, 1);
# Move the cursor to the object containing the tooltip
web_cursor_to_obj(object, 1, 1);
# Move the cursor back and forth to trigger the tooltip to pop up
move_locator_rel(0,1);
move_locator_rel(0,-1);
# Wait for the tooltip. This is time consuming, something to keep in mind when
# you want to use this function
wait(2);
# Check on visibility of the tooltip window, otherwise a standard tooltip does not exist for this object
if((rc = win_exists("{class: window, MSW_class: \"tooltips_class32\",displayed: 1}")) == E_OK)
# Capture the text
return win_get_info("{class: window, MSW_class: \"tooltips_class32\",displayed: 1}","text",text);
return rc;
}
Keep in mind, this only works with standard tooltips, recognizable on the title='[text]' attribute in the HTML tag (not always visible when CSS is used). When the tooltip is a customized tooltip created by some JavaScript, most probably it is created as a frame object and you'll have to capture the text of that frame object in stead.
July 1, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment