Skip to content

Instantly share code, notes, and snippets.

@adzap
Created May 30, 2009 05:49
Show Gist options
  • Save adzap/120398 to your computer and use it in GitHub Desktop.
Save adzap/120398 to your computer and use it in GitHub Desktop.
Then /^I should see "([^\"]*)" value updated to "([^\"]*)"$/ do |dom_id, value|
current_value_of(dom_id).should == value
end
Then /^I should see "([^\"]*)" text updated to "([^\"]*)"$/ do |dom_id, value|
current_text_of(dom_id).should == value
end
def current_value_of(dom_id)
dom_id = "##{dom_id}" unless dom_id.starts_with?('#')
eval_javascript("$('#{dom_id}').val()")
end
def current_text_of(dom_id)
dom_id = "##{dom_id}" unless dom_id.starts_with?('#')
eval_javascript("$('#{dom_id}').text()")
end
def eval_javascript(javascript)
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
selenium.get_eval("window.#{javascript}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment