lib/mohawk/adapters/uia/window.rb in mohawk-0.2.1 vs lib/mohawk/adapters/uia/window.rb in mohawk-0.3
- old
+ new
@@ -12,15 +12,11 @@
@locator = locator
@container = container
end
def element
- @element ||= Uia.find_element(@locator)
- if @element && @container
- @element = @element.find(@container) || @element
- end
- @element
+ @element ||= locate_element
end
def send_keys(*keys)
activate
element.send_keys keys
@@ -38,11 +34,11 @@
def exist?
Mohawk::Win32.is_window handle
end
def handle
- element.handle
+ (locate_element && element.handle) || 0
end
def title
element.name
end
@@ -50,14 +46,23 @@
def text
element.descendants.map &:name
end
def present?
- element != nil
+ locate_element != nil
end
def wait_until_present
wait_until { element }
+ end
+
+ private
+ def locate_element
+ element = Uia.find_element(@locator)
+ if element && @container
+ element = element.find(@container) || element
+ end
+ element
end
end
end
end
end
\ No newline at end of file