def wait_for_expected_title(expected_title, timeout=::PageObject.default_element_wait)
      define_method("wait_for_expected_title?") do
        error_message = lambda { "Expected title '#{expected_title}' instead of '#{title}'" }

        has_expected_title = (expected_title === title)
        wait_until(timeout, error_message.call) do
          has_expected_title = (expected_title === title)
        end unless has_expected_title

        raise error_message.call unless has_expected_title
        has_expected_title
      end
    end
def wait_for_expected_title(expected_title, timeout=::PageObject.default_element_wait)
      define_method("wait_for_expected_title?") do
        error_message = lambda { "Expected title '#{expected_title}' instead of '#{title}'" }

        has_expected_title = (expected_title === title)
        wait_until(timeout, error_message.call) do
          has_expected_title = (expected_title === title)
        end unless has_expected_title

        raise error_message.call unless has_expected_title
        has_expected_title
      end
    end
Creates a method that waits the expected_title of a page to match the actual.
 @param [String] expected_title the literal expected title for the page
 @param [Regexp] expected_title the expected title pattern for the page
 @param [optional, Integer] timeout default value is nil - do not wait
 @return [boolean]
 @raise An exception if expected_title does not match actual title

 @example Specify 'Google' as the expected title of a page
   expected_title "Google"
   page.has_expected_title?