public static bool HasJQuery(this Session session)
{
// given the way the JavaScript is executed, using the simple variable name 'jQuery' here throws an InvalidOperationException
// this can be reproduced in the browser (tested in Chrome) by running "new Function('return !!jQuery;')()" in the developer console
// on a page that does not have a jQuery variable defined
return session.ExecuteJavaScript<bool>(@"return !!window[""jQuery""];");
}
}