Created
September 11, 2015 16:14
-
-
Save mir4a/f231759730114c86a6d4 to your computer and use it in GitHub Desktop.
Setter/getter for some particular global var and increment on each Ajax request for Capybara tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_ajax_counter(global_var) | |
page.execute_script <<-SCRIPT | |
window["#{global_var}"] = 0; | |
$(document).on("ajaxSend", function(){ | |
window["#{global_var}"]++; | |
console.log('increment ajax counter window["#{global_var}"] = ' + window["#{global_var}"]); | |
}); | |
SCRIPT | |
end | |
def get_js_global_var(global_var) | |
page.evaluate_script <<-SCRIPT | |
window["#{global_var}"] | |
SCRIPT | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment