Method: Sikuli::Searchable#wait

Defined in:
lib/sikuli/searchable.rb

#wait(filename, time = 2, similarity = 0.9) ⇒ Object

Public: wait for a match to appear within a region

filename - A String representation of the filename to match against time - A Fixnum representing the amount of time to wait defaults to 2 seconds similarity - A Float between 0 and 1 representing the threshold for matching an image. Passing 1 corresponds to a 100% pixel for pixel match. Defaults to 0.9 (90% match)

Examples

region.wait('needle.png') # wait for needle.png to appear for up to 1 second
region.wait('needle.png', 10) # wait for needle.png to appear for 10 seconds

Returns nothing

Throws Sikuli::FileNotFound if the file could not be found on the system Throws Sikuli::ImageNotMatched if no matches are found within the region



109
110
111
112
113
114
115
116
117
118
# File 'lib/sikuli/searchable.rb', line 109

def wait(filename, time = 2, similarity = 0.9)
  begin
    pattern = build_pattern(filename, similarity)
    match = Region.new(@java_obj.wait(pattern, time))
    match.highlight if Sikuli::Config.highlight_on_find
    match
  rescue NativeException => e
    raise_exception e, filename
  end
end