Skip to content

Instantly share code, notes, and snippets.

@AutomatedTester
Created March 21, 2012 20:54
Show Gist options
  • Select an option

  • Save AutomatedTester/2152763 to your computer and use it in GitHub Desktop.

Select an option

Save AutomatedTester/2152763 to your computer and use it in GitHub Desktop.
is_displayed atom
function(){return function(){var g=void 0,h=!0,i=null,j=!1,k=this;
function l(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function m(a,b){function c(){}c.prototype=b.prototype;a.h=b.prototype;a.prototype=new c};function aa(a,b){for(var c=1;c<arguments.length;c++)var d=(""+arguments[c]).replace(/\$/g,"$$$$"),a=a.replace(/\%s/,d);return a}function n(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")}var o={};function ba(a){return o[a]||(o[a]=(""+a).replace(/\-([a-z])/g,function(a,c){return c.toUpperCase()}))};var p,ca="",q=/rv\:([^\);]+)(\)|;)/.exec(k.navigator?k.navigator.userAgent:i);p=ca=q?q[1]:"";var r={};function s(a,b){this.code=a;this.message=b||"";this.name=t[a]||t[13];var c=Error(this.message);c.name=this.name;this.stack=c.stack||""}m(s,Error);
var t={7:"NoSuchElementError",8:"NoSuchFrameError",9:"UnknownCommandError",10:"StaleElementReferenceError",11:"ElementNotVisibleError",12:"InvalidElementStateError",13:"UnknownError",15:"ElementNotSelectableError",19:"XPathLookupError",23:"NoSuchWindowError",24:"InvalidCookieDomainError",25:"UnableToSetCookieError",26:"ModalDialogOpenedError",27:"NoModalDialogOpenError",28:"ScriptTimeoutError",32:"InvalidSelectorError",33:"SqlDatabaseError",34:"MoveTargetOutOfBoundsError"};
s.prototype.toString=function(){return"["+this.name+"] "+this.message};function u(a){this.stack=Error().stack||"";a&&(this.message=""+a)}m(u,Error);u.prototype.name="CustomError";function v(a,b){b.unshift(a);u.call(this,aa.apply(i,b));b.shift()}m(v,u);v.prototype.name="AssertionError";function da(a,b){for(var c=a.length,d="string"==typeof a?a.split(""):a,f=0;f<c;f++)if(f in d&&b.call(g,d[f],f,a))return h;return j};var w;
if(!r["1.9.1"]){for(var x=0,y=n(""+p).split("."),z=n("1.9.1").split("."),ea=Math.max(y.length,z.length),A=0;0==x&&A<ea;A++){var fa=y[A]||"",ga=z[A]||"",ha=RegExp("(\\d*)(\\D*)","g"),ia=RegExp("(\\d*)(\\D*)","g");do{var B=ha.exec(fa)||["","",""],C=ia.exec(ga)||["","",""];if(0==B[0].length&&0==C[0].length)break;x=((0==B[1].length?0:parseInt(B[1],10))<(0==C[1].length?0:parseInt(C[1],10))?-1:(0==B[1].length?0:parseInt(B[1],10))>(0==C[1].length?0:parseInt(C[1],10))?1:0)||((0==B[2].length)<(0==C[2].length)?-1:
(0==B[2].length)>(0==C[2].length)?1:0)||(B[2]<C[2]?-1:B[2]>C[2]?1:0)}while(0==x)}r["1.9.1"]=0<=x};function D(a,b){this.x=a!==g?a:0;this.y=b!==g?b:0}D.prototype.toString=function(){return"("+this.x+", "+this.y+")"};function F(a,b){this.width=a;this.height=b}F.prototype.toString=function(){return"("+this.width+" x "+this.height+")"};var ja=3;function G(a){return 9==a.nodeType?a:a.ownerDocument||a.document}function ka(a,b){var c=[];return H(a,b,c,h)?c[0]:g}function H(a,b,c,d){if(a!=i)for(a=a.firstChild;a;){if(b(a)&&(c.push(a),d)||H(a,b,c,d))return h;a=a.nextSibling}return j}function I(a,b){for(var a=a.parentNode,c=0;a;){if(b(a))return a;a=a.parentNode;c++}return i}function J(a){this.g=a||k.document||document}
function K(a){var b=a.g,a="CSS1Compat"==b.compatMode?b.documentElement:b.body,b=b.parentWindow||b.defaultView;return new D(b.pageXOffset||a.scrollLeft,b.pageYOffset||a.scrollTop)};var la=function(){var a={i:"http://www.w3.org/2000/svg"};return function(b){return a[b]||i}}();
function ma(a,b){var c=function(){var c;a:{var f=G(b);if(f.implementation.hasFeature("XPath","3.0")){try{var e=f.createNSResolver?f.createNSResolver(f.documentElement):la;c=f.evaluate(a,b,e,9,i);break a}catch(E){if("NS_ERROR_ILLEGAL_VALUE"!=E.name)throw new s(32,"Unable to locate an element with the xpath expression "+a+" because of the following error:\n"+E);}c=g}else c=i}if(c)return c.singleNodeValue||i;return b.selectSingleNode?(c=G(b),c.setProperty&&c.setProperty("SelectionLanguage","XPath"),
b.selectSingleNode(a)):i}();if(c!==i&&(!c||1!=c.nodeType))throw new s(32,'The result of the xpath expression "'+a+'" is: '+c+". It should be an element.");return c};(function(){var a=k.Components;if(!a)return j;try{if(!a.classes)return j}catch(b){return j}var c=a.classes,a=a.interfaces;c["@mozilla.org/xpcom/version-comparator;1"].getService(a.nsIVersionComparator);c["@mozilla.org/xre/app-info;1"].getService(a.nsIXULAppInfo);return h})();var L="StopIteration"in k?k.StopIteration:Error("StopIteration");function M(){}M.prototype.next=function(){throw L;};function O(a,b,c,d,f){this.a=!!b;a&&P(this,a,d);this.depth=f!=g?f:this.c||0;this.a&&(this.depth*=-1);this.f=!c}m(O,M);O.prototype.b=i;O.prototype.c=0;O.prototype.e=j;function P(a,b,c){if(a.b=b)a.c="number"==typeof c?c:1!=a.b.nodeType?0:a.a?-1:1}
O.prototype.next=function(){var a;if(this.e){if(!this.b||this.f&&0==this.depth)throw L;a=this.b;var b=this.a?-1:1;if(this.c==b){var c=this.a?a.lastChild:a.firstChild;c?P(this,c):P(this,a,-1*b)}else(c=this.a?a.previousSibling:a.nextSibling)?P(this,c):P(this,a.parentNode,-1*b);this.depth+=this.c*(this.a?-1:1)}else this.e=h;a=this.b;if(!this.b)throw L;return a};
O.prototype.splice=function(a){var b=this.b,c=this.a?1:-1;this.c==c&&(this.c=-1*c,this.depth+=this.c*(this.a?-1:1));this.a=!this.a;O.prototype.next.call(this);this.a=!this.a;for(var c=arguments[0],d=l(c),c="array"==d||"object"==d&&"number"==typeof c.length?arguments[0]:arguments,d=c.length-1;0<=d;d--)b.parentNode&&b.parentNode.insertBefore(c[d],b.nextSibling);b&&b.parentNode&&b.parentNode.removeChild(b)};function Q(a,b,c,d){O.call(this,a,b,c,i,d)}m(Q,O);Q.prototype.next=function(){do Q.h.next.call(this);while(-1==this.c);return this.b};function R(a,b){var c=G(a);return c.defaultView&&c.defaultView.getComputedStyle&&(c=c.defaultView.getComputedStyle(a,i))?c[b]||c.getPropertyValue(b):""}function S(a,b){return R(a,b)||(a.currentStyle?a.currentStyle[b]:i)||a.style&&a.style[b]}
function na(a){for(var b=G(a),c=S(a,"position"),d="fixed"==c||"absolute"==c,a=a.parentNode;a&&a!=b;a=a.parentNode)if(c=S(a,"position"),d=d&&"static"==c&&a!=b.documentElement&&a!=b.body,!d&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight||"fixed"==c||"absolute"==c||"relative"==c))return a;return i}
function oa(a){var b=new D;if(1==a.nodeType)if(a.getBoundingClientRect)a=a.getBoundingClientRect(),b.x=a.left,b.y=a.top;else{var c=K(a?new J(G(a)):w||(w=new J));var d,f=G(a),e=S(a,"position"),E=f.getBoxObjectFor&&!a.getBoundingClientRect&&"absolute"==e&&(d=f.getBoxObjectFor(a))&&(0>d.screenX||0>d.screenY),e=new D(0,0),N=(f?9==f.nodeType?f:G(f):document).documentElement;if(a!=N)if(a.getBoundingClientRect)d=a.getBoundingClientRect(),a=K(f?new J(G(f)):w||(w=new J)),e.x=d.left+a.x,e.y=d.top+a.y;else if(f.getBoxObjectFor&&
!E)d=f.getBoxObjectFor(a),a=f.getBoxObjectFor(N),e.x=d.screenX-a.screenX,e.y=d.screenY-a.screenY;else{d=a;do e.x+=d.offsetLeft,e.y+=d.offsetTop,d!=a&&(e.x+=d.clientLeft||0,e.y+=d.clientTop||0),d=d.offsetParent;while(d&&d!=a);for(d=a;(d=na(d))&&d!=f.body&&d!=N;)e.x-=d.scrollLeft,e.y-=d.scrollTop}b.x=e.x-c.x;b.y=e.y-c.y}else c="function"==l(a.d),d=a,a.targetTouches?d=a.targetTouches[0]:c&&a.d().targetTouches&&(d=a.d().targetTouches[0]),b.x=d.clientX,b.y=d.clientY;return b}
function pa(a){var b=a.offsetWidth,c=a.offsetHeight;return b===g&&a.getBoundingClientRect?(a=a.getBoundingClientRect(),new F(a.right-a.left,a.bottom-a.top)):new F(b,c)};function T(a,b){return!!a&&1==a.nodeType&&(!b||a.tagName.toUpperCase()==b)}var U="async,autofocus,autoplay,checked,compact,complete,controls,declare,defaultchecked,defaultselected,defer,disabled,draggable,ended,formnovalidate,hidden,indeterminate,iscontenteditable,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,paused,pubdate,readonly,required,reversed,scoped,seamless,seeking,selected,spellcheck,truespeed,willvalidate".split(",");
function V(a){for(a=a.parentNode;a&&1!=a.nodeType&&9!=a.nodeType&&11!=a.nodeType;)a=a.parentNode;return T(a)?a:i}function W(a,b){b=ba(b);return R(a,b)||qa(a,b)}function qa(a,b){var c=a.currentStyle||a.style,d=c[b];d===g&&"function"==l(c.getPropertyValue)&&(d=c.getPropertyValue(b));return"inherit"!=d?d!==g?d:i:(c=V(a))?qa(c,b):i}
function ra(a){if("function"==l(a.getBBox))try{var b=a.getBBox();if(b)return b}catch(c){}if("none"!=S(a,"display"))a=pa(a);else{var b=a.style,d=b.display,f=b.visibility,e=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";a=pa(a);b.display=d;b.position=e;b.visibility=f}return a}
function X(a,b){function c(a){if("none"==W(a,"display"))return j;a=V(a);return!a||c(a)}function d(a){var b=ra(a);return 0<b.height&&0<b.width?h:da(a.childNodes,function(a){return a.nodeType==ja||T(a)&&d(a)})}function f(a){var b=V(a);if(b&&"hidden"==W(b,"overflow")){var c=ra(b),d=oa(b),a=oa(a);return d.x+c.width<a.x||d.y+c.height<a.y?j:f(b)}return h}if(!T(a))throw Error("Argument to isShown must be of type Element");if(T(a,"OPTION")||T(a,"OPTGROUP")){var e=I(a,function(a){return T(a,"SELECT")});return!!e&&
X(e,h)}if(T(a,"MAP")){if(!a.name)return j;e=G(a);e=e.evaluate?ma('/descendant::*[@usemap = "#'+a.name+'"]',e):ka(e,function(b){var c;if(c=T(b)){if(8==b.nodeType)c=i;else if(c="usemap","style"==c)c=n(b.style.cssText).toLowerCase(),c=";"==c.charAt(c.length-1)?c:c+";";else if(b=b.getAttributeNode(c)){b:if("string"==typeof U)c="string"!=typeof c||1!=c.length?-1:U.indexOf(c,0);else{for(var d=0;d<U.length;d++)if(d in U&&U[d]===c){c=d;break b}c=-1}c=0<=c?"true":b.specified?b.value:i}else c=i;c=c=="#"+a.name}return c});
return!!e&&X(e,b)}return T(a,"AREA")?(e=I(a,function(a){return T(a,"MAP")}),!!e&&X(e,b)):T(a,"INPUT")&&"hidden"==a.type.toLowerCase()||T(a,"NOSCRIPT")||"hidden"==W(a,"visibility")||!c(a)||!b&&0==sa(a)||!d(a)||!f(a)?j:h}function sa(a){var b=1,c=W(a,"opacity");c&&(b=Number(c));(a=V(a))&&(b*=sa(a));return b};var ta=X,Y=["_"],Z=k;!(Y[0]in Z)&&Z.execScript&&Z.execScript("var "+Y[0]);for(var $;Y.length&&($=Y.shift());)!Y.length&&ta!==g?Z[$]=ta:Z=Z[$]?Z[$]:Z[$]={};; return this._.apply(null,arguments);}.apply({navigator:typeof window!='undefined'?window.navigator:null}, arguments);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment