lib/page.rb in gridium-1.1.20 vs lib/page.rb in gridium-1.1.21
- old
+ new
@@ -16,23 +16,35 @@
else
Log.info("[GRIDIUM::Page] Asserted Element present with locator #{locator} using #{by}")
end
end
- def self.has_css?(css, options={})
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
+ def self.has_css?(css, opts = {})
+ timeout = opts[:timeout] || 5
+ wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
begin
- wait.until {Driver.driver.find_element(:css, css).enabled?}
+ element = Driver.driver.find_element :css, css
+ if opts[:visible]
+ wait.until {element.displayed?}
+ else
+ wait.until {element.enabled?}
+ end
rescue Exception => exception
Log.debug("[GRIDIUM::Page] has_css? is false because this exception was rescued: #{exception}")
return false
end
end
- def self.has_xpath?(xpath, options={})
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
+ def self.has_xpath?(xpath, opts = {})
+ timeout = opts[:timeout] || 5
+ wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
begin
- wait.until {Driver.driver.find_element(:xpath, xpath).enabled?}
+ element = Driver.driver.find_element :xpath, xpath
+ if opts[:visible]
+ wait.until {element.displayed?}
+ else
+ wait.until {element.enabled?}
+ end
rescue Exception => exception
Log.debug("[GRIDIUM::Page] has_xpath? is false because this exception was rescued: #{exception}")
return false
end
end