lib/fluent/generators.rb in fluent-0.2.0 vs lib/fluent/generators.rb in fluent-0.3.0

- old
+ new

@@ -6,10 +6,16 @@ raise Fluent::Errors::NoUrlForDefinition, msg if url.nil? define_method('view') do platform.visit(url) end + + define_method('check_url') do + msg = "Expected url: '#{url}'; Actual url: '#{browser.url}'" + valid_url = url == browser.url + raise Fluent::Errors::UrlNotMatched, msg unless valid_url + end end def title_is(title=nil) msg = "The title_is assertion is empty on the definition #{self}." raise Fluent::Errors::NoTitleForDefinition, msg if title.nil? @@ -46,18 +52,20 @@ define_method(identifier) do return platform.link_click(locator.clone) end common_definition_methods(identifier, locator, __method__) + common_definition_methods(identifier, locator, 'a') end def paragraph(identifier, locator) define_method(identifier) do return platform.paragraph_text(locator.clone) end common_definition_methods(identifier, locator, __method__) + common_definition_methods(identifier, locator, 'p') end def div(identifier, locator) define_method(identifier) do return platform.div_text(locator.clone) @@ -90,10 +98,11 @@ define_method("#{identifier}=") do |value| return platform.text_field_set(locator.clone, value) end common_definition_methods(identifier, locator, __method__) + common_definition_methods(identifier, locator, 'textfield') end def text_area(identifier, locator) define_method(identifier) do return platform.text_area_get(locator.clone) @@ -102,10 +111,11 @@ define_method("#{identifier}=") do |value| return platform.text_area_set(locator.clone, value) end common_definition_methods(identifier, locator, __method__) + common_definition_methods(identifier, locator, 'textarea') end def checkbox(identifier, locator) define_method("#{identifier}_checked?") do return platform.checkbox_check_state(locator.clone) @@ -156,10 +166,11 @@ alias_method "#{identifier}_set?".to_sym, "#{identifier}_selected?".to_sym alias_method "set_#{identifier}".to_sym, "select_#{identifier}".to_sym common_definition_methods(identifier, locator, __method__) + common_definition_methods(identifier, locator, 'radio_button') end def ordered_list(identifier, locator) define_method(identifier) do return platform.ordered_list_text(locator.clone) @@ -202,17 +213,67 @@ common_definition_methods(identifier, locator, __method__) common_definition_methods(identifier, locator, 'td') end - alias_method :radio_button, :radio ### - alias_method :textarea, :text_area ### - alias_method :textfield, :text_field ### - alias_method :a, :link ### + def label(identifier, locator) + define_method(identifier) do + return platform.label_text(locator.clone) + end + + common_definition_methods(identifier, locator, __method__) + end + + def hidden(identifier, locator) + define_method(identifier) do + return platform.hidden_value(locator.clone) + end + + common_definition_methods(identifier, locator, __method__) + end + + def form(identifier, locator) + common_definition_methods(identifier, locator, __method__) + end + + def image(identifier, locator) + common_definition_methods(identifier, locator, __method__) + common_definition_methods(identifier, locator, 'img') + end + + [:h1, :h2, :h3, :h4, :h5, :h6].each do |method| + define_method(method) do |identifier, locator| + define_method(identifier) do + platform_method = "#{method.to_s}_text" + return platform.send(platform_method, locator.clone) + end + + common_definition_methods(identifier, locator, method) + end + end + + #def h1(identifier, locator) + + #end + + #def h2(identifier, locator) + + #end + + #def h3(identifier, locator) + + #end + + alias_method :radio_button, :radio + alias_method :textarea, :text_area + alias_method :textfield, :text_field + alias_method :a, :link + alias_method :p, :paragraph alias_method :ol, :ordered_list alias_method :ul, :unordered_list alias_method :li, :list_item alias_method :td, :cell + alias_method :img, :image def common_definition_methods(identifier, locator, method) define_method("#{identifier}_object") do platform.send(method, locator.clone) end \ No newline at end of file