lib/page.rb in gridium-1.1.13 vs lib/page.rb in gridium-1.1.14
- old
+ new
@@ -46,21 +46,27 @@
Log.debug("[GRIDIUM::Page] has_link? is false because this exception was rescued: #{exception}")
return false
end
end
- def self.has_text?(text)
- has_flash?(text)
+
+ def self.has_text?(text, opts = {})
+ has_flash?(text, opts)
end
- def self.has_flash?(text)
- wait = Selenium::WebDriver::Wait.new(:timeout => 5) #5 seconds every 500ms
+ def self.has_flash?(text, opts = {})
+ timeout = opts[:timeout] || 5
+ wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
begin
- element = wait.until {Driver.html.include? text}
+ if opts[:visible]
+ element = wait.until { Element.new("Finding text '#{text}'", :xpath, "//*[text()='#{text}']").displayed? }
+ else
+ element = wait.until { Driver.html.include? text }
+ end
rescue Exception => exception
- Log.debug("[GRIDIUM::Page] has_flash? exception was rescued: #{exception}")
- Log.warn("[GRIDIUM::Page] Could not find the flash message!")
+ Log.debug("[GRIDIUM::Page] exception was rescued: #{exception}")
+ Log.warn("[GRIDIUM::Page] Could not find the text '#{text}'!")
end
if element
return true
else
@@ -120,10 +126,10 @@
def first(by, locator)
all(by, locator).first
end
def click_on(text)
- Element.new("Clicking #{text}", :xpath, "//*[text()='#{text}')]").click
+ Element.new("Clicking #{text}", :xpath, "//*[text()='#{text}']").click
end
# Click the link on the page
# @param [String] link_text - Text of the link to click
# @param [Integer] link_index (optional) - With multiple links on the page with the same name, click on the specified link index