Module: AppPrism::Finders

Included in:
Sections::ScreenSection
Defined in:
lib/app_prism/finders.rb

Instance Method Summary collapse

Instance Method Details

#element(name, identifiers) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/app_prism/finders.rb', line 9

def element(name, identifiers)
  define_method("#{name}_element") do
    get_element_for(identifiers)
  end

  define_method(name) do |&block|
    get_element_for(identifiers).click
  end

  define_method("#{name}?") do
    get_element_for(identifiers).visible?
  end

  define_method("#{name}=") do |value|
    get_element_for(identifiers).send_keys(value)
  end
end

#elements(name, identifiers) ⇒ Object



27
28
29
30
31
# File 'lib/app_prism/finders.rb', line 27

def elements(name, identifiers)
  define_method("#{name}_elements") do
    get_elements_for(identifiers)
  end
end

#expected_element(name, wait_time = 0, timeout = AppPrism::DEFAULT_WAIT_TIME) ⇒ Object



33
34
35
36
37
38
# File 'lib/app_prism/finders.rb', line 33

def expected_element(name, wait_time = 0, timeout = AppPrism::DEFAULT_WAIT_TIME)
  define_method("has_expected_element?") do
    sleep wait_time
    self.respond_to?("#{name}_element") && self.send("#{name}_element").when_visible(timeout)
  end
end