Module: Polonium::SeleniumDsl

Includes:
WaitFor
Included in:
TestCase
Defined in:
lib/polonium/dsl/selenium_dsl.rb

Instance Attribute Summary collapse

Attributes included from WaitFor

#default_timeout

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WaitFor

#default_wait_for_time, #flunk, #time_class, #wait_for

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (protected)



79
80
81
82
83
84
85
# File 'lib/polonium/dsl/selenium_dsl.rb', line 79

def method_missing(method_name, *args, &block)
  if selenium_driver.respond_to?(method_name)
    selenium_driver.__send__(method_name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#selenium_driverObject

Returns the value of attribute selenium_driver.



64
65
66
# File 'lib/polonium/dsl/selenium_dsl.rb', line 64

def selenium_driver
  @selenium_driver
end

Class Method Details

.element_assertion(name) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/polonium/dsl/selenium_dsl.rb', line 14

def element_assertion(name)
  module_eval(
    "def assert_#{name}(locator, *args)\n" +
    "  element(locator).assert_#{name}(*args)\n" +
    "end",
    __FILE__,
    __LINE__ - 4
  )
end

.page_assertion(name) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/polonium/dsl/selenium_dsl.rb', line 4

def page_assertion(name)
  module_eval(
    "def assert_#{name}(value, params={})\n" +
    "  page.assert_#{name}(value, params)\n" +
    "end",
    __FILE__,
    __LINE__ - 4
  )
end

Instance Method Details

#assert_attribute(element_locator, attribute_name, expected_value) ⇒ Object



43
44
45
# File 'lib/polonium/dsl/selenium_dsl.rb', line 43

def assert_attribute(element_locator, attribute_name, expected_value)
  element(element_locator).assert_attribute(attribute_name, expected_value)
end

#assert_element_contains(locator, text, options = {}) ⇒ Object Also known as: assert_element_contains_text

Assert and wait for locator element to contain text.



48
49
50
# File 'lib/polonium/dsl/selenium_dsl.rb', line 48

def assert_element_contains(locator, text, options = {})
  element(locator).assert_contains(text, options)
end

#assert_element_does_not_contain(locator, text, options = {}) ⇒ Object

Assert and wait for locator element to not contain text.



54
55
56
# File 'lib/polonium/dsl/selenium_dsl.rb', line 54

def assert_element_does_not_contain(locator, text, options={})
  element(locator).assert_does_not_contain(text, options)
end

#configurationObject



74
75
76
# File 'lib/polonium/dsl/selenium_dsl.rb', line 74

def configuration
  Polonium::Configuration.instance
end

#download(path) ⇒ Object

Download a file from the Application Server



68
69
70
71
72
# File 'lib/polonium/dsl/selenium_dsl.rb', line 68

def download(path)
  uri = URI.parse(configuration.browser_url + path)
  puts "downloading #{uri.to_s}"
  Net::HTTP.get(uri)
end

#element_contains_text(locator, text) ⇒ Object

Does the element at locator contain the text?



60
61
62
# File 'lib/polonium/dsl/selenium_dsl.rb', line 60

def element_contains_text(locator, text)
  element(locator).assert_contains(text)
end