lib/page.rb in gridium-0.1.15 vs lib/page.rb in gridium-0.1.16
- old
+ new
@@ -20,29 +20,29 @@
def self.has_css?(css, options={})
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
begin
wait.until {Driver.driver.find_element(:css, css).enabled?}
- rescue Exception => e
+ rescue Exception
return false
end
end
def self.has_xpath?(xpath, options={})
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
begin
wait.until {Driver.driver.find_element(:xpath, xpath).enabled?}
- rescue Exception => e
+ rescue Exception
return false
end
end
def self.has_link?(linktext)
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
begin
wait.until {Driver.driver.find_element(:link_text, linktext).enabled?}
- rescue Exception => e
+ rescue Exception
return false
end
end
def self.has_text?(text)
@@ -75,10 +75,24 @@
def self.execute_script(script)
Driver.execute_script_driver(script)
end
+ def self.evaluate_script(script)
+ Driver.evaluate_script script
+ end
+
+ def self.wait_for_ajax
+ Timeout.timeout(Gridium.config.page_load_timeout) do
+ loop until jquery_loaded?
+ end
+ end
+
+ def self.jquery_loaded?
+ self.evaluate_script("jQuery.active").zero?
+ end
+
def all(by, locator)
Driver.driver.find_elements(by, locator)
end
def find(by, locator)
@@ -96,10 +110,10 @@
def click_button(button_name)
#The button maybe a link that looks like a button - we want to handle both
button = Element.new("A #{button_name} button", :xpath, "//button[contains(., '#{button_name}')]")
begin
button.click
- rescue Exception => e
+ rescue Exception
Log.debug("Button not found - Attempting Link - speed up test by using click_link method if this works...")
link = Element.new("A #{button_name} link", :xpath, "//a[contains(., '#{button_name}')]")
link.click
end
end