Created
July 8, 2010 23:38
-
-
Save keturn/468808 to your computer and use it in GitHub Desktop.
getAjaxResult for python selenium
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 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