lib/page-object/elements/element.rb in page-object-0.3.2 vs lib/page-object/elements/element.rb in page-object-0.4.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'mixology' + module PageObject module Elements # # Contains functionality that is common across all elements. # @@ -14,10 +16,28 @@ def initialize(element, platform) @element = element include_platform_for platform end + # + # click the element + # + def click + @element.click + end + + # + # get the value of the given CSS property + # + def style(property) + @element.style property + end + + def inspect + @element.inspect + end + # @private def self.watir_identifier_for identifier if should_build_watir_xpath(identifier) how = :xpath what = build_xpath_for(identifier) @@ -56,11 +76,11 @@ end protected def self.should_build_watir_xpath identifier - ['table', 'span', 'div', 'td', 'li', 'ul', 'ol', 'h1', 'h2', 'h3'].include? identifier[:tag_name] and identifier[:name] + ['table', 'span', 'div', 'td', 'li', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'].include? identifier[:tag_name] and identifier[:name] end def self.build_xpath_for identifier tag_locator = identifier.delete(:tag_name) idx = identifier.delete(:index) @@ -135,15 +155,15 @@ def include_platform_for platform if platform[:platform] == :watir_webdriver require 'page-object/platforms/watir_webdriver/element' require 'page-object/platforms/watir_webdriver/page_object' - self.class.send :include, PageObject::Platforms::WatirWebDriver::Element + self.mixin PageObject::Platforms::WatirWebDriver::Element @platform = PageObject::Platforms::WatirWebDriver::PageObject.new(@element) elsif platform[:platform] == :selenium_webdriver require 'page-object/platforms/selenium_webdriver/element' require 'page-object/platforms/selenium_webdriver/page_object' - self.class.send :include, PageObject::Platforms::SeleniumWebDriver::Element + self.mixin PageObject::Platforms::SeleniumWebDriver::Element @platform = PageObject::Platforms::SeleniumWebDriver::PageObject.new(@element) else raise ArgumentError, "expect platform to be :watir_webdriver or :selenium_webdriver" end end