I'm a Java developer, I'm new to Ruby and I'm worried that I'm forcing or not-so-well using the goodness of the Ruby syntax.
- What do you think about the Exception catching and how to print it in error messages?
- What about the code block (closure?) I'm passing to the "until" method?
- Is it ok to implicitly rely on what the last executed sentence of the block will be, regarding what would be its returned value?
def waitUntilDisappears(type, name) #Waits for a particular element to disappear begin puts "Waiting for element #{name} to disappear..." wait = Selenium::WebDriver::Wait.new(:timeout => 5) wait.until do element = driver.find_element(type, name) if element != nil displayValue = element.css_value("display") puts "Element #{name} has displayValue #{displayValue}." displayValue != "block" end end puts "Element #{name} disappeared or not present. OK." rescue Exception => e puts "Error: Could not wait for element #{name} to disappearDetails: #{e.inspect}" end end