Skip to content

Instantly share code, notes, and snippets.

@keturn
Created July 8, 2010 23:38
Show Gist options
  • Save keturn/468808 to your computer and use it in GitHub Desktop.
Save keturn/468808 to your computer and use it in GitHub Desktop.
getAjaxResult for python selenium
def getAjaxResult(self, func, *args):
sel = self.selenium
self.js('''\
ajaxSeleniumResult = (function (func, args) {
var result = [], funcArgs;
function storeSeleniumResult() {
result.push(window.jQuery.makeArray(arguments));
}
// assume function's last argument is a callback
args.push(storeSeleniumResult);
func.apply(null, args);
return result;
}(%s, %%s));
''' % (func,), args)
sel.wait_for_condition('ajaxSeleniumResult.length !== 0', 1500);
return simplejson.loads(
sel.get_eval('window.jQuery.toJSON(ajaxSeleniumResult[0]);'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment