selenium-atoms
Version:
17 lines (16 loc) • 9.26 kB
JavaScript
function(){return function(){var e=this;
function g(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 aa(a){var b=g(a);return"array"==b||"object"==b&&"number"==typeof a.length}function ba(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}function m(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=c.slice();b.push.apply(b,arguments);return a.apply(this,b)}}var n=Date.now||function(){return+new Date};function p(a,b){this.code=a;this.b=r[a]||t;this.message=b||"";var c=this.b.replace(/((?:^|\s+)[a-z])/g,function(a){return a.toUpperCase().replace(/^[\s\xa0]+/g,"")}),d=c.length-5;if(0>d||c.indexOf("Error",d)!=d)c+="Error";this.name=c;c=Error(this.message);c.name=this.name;this.stack=c.stack||""}
(function(){var a=Error;function b(){}b.prototype=a.prototype;p.c=a.prototype;p.prototype=new b;p.prototype.constructor=p;p.b=function(b,d,h){for(var f=Array(arguments.length-2),k=2;k<arguments.length;k++)f[k-2]=arguments[k];return a.prototype[d].apply(b,f)}})();var t="unknown error",r={15:"element not selectable",11:"element not visible"};r[31]=t;r[30]=t;r[24]="invalid cookie domain";r[29]="invalid element coordinates";r[12]="invalid element state";r[32]="invalid selector";r[51]="invalid selector";
r[52]="invalid selector";r[17]="javascript error";r[405]="unsupported operation";r[34]="move target out of bounds";r[27]="no such alert";r[7]="no such element";r[8]="no such frame";r[23]="no such window";r[28]="script timeout";r[33]="session not created";r[10]="stale element reference";r[21]="timeout";r[25]="unable to set cookie";r[26]="unexpected alert open";r[13]=t;r[9]="unknown command";p.prototype.toString=function(){return this.name+": "+this.message};var v=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")};
function w(a,b){for(var c=0,d=v(String(a)).split("."),h=v(String(b)).split("."),f=Math.max(d.length,h.length),k=0;0==c&&k<f;k++){var x=d[k]||"",l=h[k]||"",F=RegExp("(\\d*)(\\D*)","g"),G=RegExp("(\\d*)(\\D*)","g");do{var u=F.exec(x)||["","",""],q=G.exec(l)||["","",""];if(0==u[0].length&&0==q[0].length)break;c=y(0==u[1].length?0:parseInt(u[1],10),0==q[1].length?0:parseInt(q[1],10))||y(0==u[2].length,0==q[2].length)||y(u[2],q[2])}while(0==c)}return c}function y(a,b){return a<b?-1:a>b?1:0};function z(a,b){for(var c=a.length,d=Array(c),h="string"==typeof a?a.split(""):a,f=0;f<c;f++)f in h&&(d[f]=b.call(void 0,h[f],f,a));return d};var A;a:{var B=e.navigator;if(B){var ca=B.userAgent;if(ca){A=ca;break a}}A=""}function C(a){return-1!=A.indexOf(a)};function da(a,b){var c={},d;for(d in a)b.call(void 0,a[d],d,a)&&(c[d]=a[d]);return c}function ea(a,b){var c={},d;for(d in a)c[d]=b.call(void 0,a[d],d,a);return c}function D(a,b){return null!==a&&b in a}function fa(a,b){for(var c in a)if(b.call(void 0,a[c],c,a))return c};function E(){return C("Opera")||C("OPR")}function H(){return(C("Chrome")||C("CriOS"))&&!E()&&!C("Edge")};function I(){return C("iPhone")&&!C("iPod")&&!C("iPad")};var ga=E(),J=C("Trident")||C("MSIE"),ha=C("Edge"),K=C("Gecko")&&!(-1!=A.toLowerCase().indexOf("webkit")&&!C("Edge"))&&!(C("Trident")||C("MSIE"))&&!C("Edge"),ia=-1!=A.toLowerCase().indexOf("webkit")&&!C("Edge");function ja(){var a=A;if(K)return/rv\:([^\);]+)(\)|;)/.exec(a);if(ha)return/Edge\/([\d\.]+)/.exec(a);if(J)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(ia)return/WebKit\/(\S+)/.exec(a)}function ka(){var a=e.document;return a?a.documentMode:void 0}
var L=function(){if(ga&&e.opera){var a;var b=e.opera.version;try{a=b()}catch(c){a=b}return a}a="";(b=ja())&&(a=b?b[1]:"");return J&&(b=ka(),b>parseFloat(a))?String(b):a}(),M={},la=e.document,ma=la&&J?ka()||("CSS1Compat"==la.compatMode?parseInt(L,10):5):void 0;var na=C("Firefox"),oa=I()||C("iPod"),pa=C("iPad"),N=C("Android")&&!(H()||C("Firefox")||E()||C("Silk")),qa=H(),ra=C("Safari")&&!(H()||C("Coast")||E()||C("Edge")||C("Silk")||C("Android"))&&!(I()||C("iPad")||C("iPod"));function O(a){return(a=a.exec(A))?a[1]:""}var sa=function(){if(na)return O(/Firefox\/([0-9.]+)/);if(J||ha||ga)return L;if(qa)return O(/Chrome\/([0-9.]+)/);if(ra&&!(I()||C("iPad")||C("iPod")))return O(/Version\/([0-9.]+)/);if(oa||pa){var a;if(a=/Version\/(\S+).*Mobile\/(\S+)/.exec(A))return a[1]+"."+a[2]}else if(N)return(a=O(/Android\s+([0-9.]+)/))?a:O(/Version\/([0-9.]+)/);return""}();var P,ta;function Q(a){R?ta(a):N?w(ua,a):w(sa,a)}var R=function(){if(!K)return!1;var a=e.Components;if(!a)return!1;try{if(!a.classes)return!1}catch(b){return!1}var c=a.classes,a=a.interfaces,d=c["@mozilla.org/xpcom/version-comparator;1"].getService(a.nsIVersionComparator),c=c["@mozilla.org/xre/app-info;1"].getService(a.nsIXULAppInfo),h=c.platformVersion,f=c.version;P=function(a){return 0<=d.compare(h,""+a)};ta=function(a){d.compare(f,""+a)};return!0}(),S;
if(N){var va=/Android\s+([0-9\.]+)/.exec(A);S=va?va[1]:"0"}else S="0";var ua=S;N&&Q(2.3);N&&Q(4);ra&&Q(6);function wa(){}
function T(a,b,c){if(null==b)c.push("null");else{if("object"==typeof b){if("array"==g(b)){var d=b;b=d.length;c.push("[");for(var h="",f=0;f<b;f++)c.push(h),T(a,d[f],c),h=",";c.push("]");return}if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();else{c.push("{");h="";for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(f=b[d],"function"!=typeof f&&(c.push(h),xa(d,c),c.push(":"),T(a,f,c),h=","));c.push("}");return}}switch(typeof b){case "string":xa(b,c);break;case "number":c.push(isFinite(b)&&
!isNaN(b)?String(b):"null");break;case "boolean":c.push(String(b));break;case "function":c.push("null");break;default:throw Error("Unknown type: "+typeof b);}}}var ya={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},za=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function xa(a,b){b.push('"',a.replace(za,function(a){var b=ya[a];b||(b="\\u"+(a.charCodeAt(0)|65536).toString(16).substr(1),ya[a]=b);return b}),'"')};ia||K&&(R?P(3.5):J?0<=w(ma,3.5):M[3.5]||(M[3.5]=0<=w(L,3.5)))||J&&(R?P(8):J?w(ma,8):M[8]||(M[8]=0<=w(L,8)));function U(a){switch(g(a)){case "string":case "number":case "boolean":return a;case "function":return a.toString();case "array":return z(a,U);case "object":if(D(a,"nodeType")&&(1==a.nodeType||9==a.nodeType)){var b={};b.ELEMENT=Aa(a);return b}if(D(a,"document"))return b={},b.WINDOW=Aa(a),b;if(aa(a))return z(a,U);a=da(a,function(a,b){return"number"==typeof b||"string"==typeof b});return ea(a,U);default:return null}}
function V(a,b){return"array"==g(a)?z(a,function(a){return V(a,b)}):ba(a)?"function"==typeof a?a:D(a,"ELEMENT")?Ba(a.ELEMENT,b):D(a,"WINDOW")?Ba(a.WINDOW,b):ea(a,function(a){return V(a,b)}):a}function Ca(a,b){if("string"==typeof a)try{return new b.Function(a)}catch(c){if(J&&b.execScript)return b.execScript(";"),new b.Function(a);throw c;}return b==window?a:new b.Function("return ("+a+").apply(null,arguments);")}
function Da(a){a=a||document;var b=a.$wdc_;b||(b=a.$wdc_={},b.a=n());b.a||(b.a=n());return b}function Aa(a){var b=Da(a.ownerDocument),c=fa(b,function(b){return b==a});c||(c=":wdc:"+b.a++,b[c]=a);return c}
function Ba(a,b){a=decodeURIComponent(a);var c=b||document,d=Da(c);if(!D(d,a))throw new p(10,"Element does not exist in cache");var h=d[a];if(D(h,"setInterval")){if(h.closed)throw delete d[a],new p(23,"Window has been closed.");return h}for(var f=h;f;){if(f==c.documentElement)return h;f=f.parentNode}delete d[a];throw new p(10,"Element is no longer attached to the DOM");};function Ea(a,b,c,d,h,f){function k(a,b){if(!G){l.removeEventListener?l.removeEventListener("unload",x,!0):l.detachEvent("onunload",x);l.clearTimeout(F);if(0!=a){var c=new p(a,b.message||b+"");c.stack=b.stack;b={status:D(c,"code")?c.code:13,value:{message:c.message}}}else b={status:0,value:U(b)};h?(c=[],T(new wa,b,c),c=c.join("")):c=b;d(c);G=!0}}function x(){k(13,Error("Detected a page unload event; asynchronous script execution does not work across page loads."))}var l=f||window,F,G=!1;f=m(k,13);
if(l.closed)f("Unable to execute script; the target window is closed.");else{a=Ca(a,l);b=V(b,l.document);b.push(m(k,0));l.addEventListener?l.addEventListener("unload",x,!0):l.attachEvent("onunload",x);var u=n();try{a.apply(l,b),F=l.setTimeout(function(){k(28,Error("Timed out waiting for asyncrhonous script result after "+(n()-u)+" ms"))},Math.max(0,c))}catch(q){k(q.code||13,q)}}}var W=["_"],X=e;W[0]in X||!X.execScript||X.execScript("var "+W[0]);
for(var Y;W.length&&(Y=W.shift());){var Z;if(Z=!W.length)Z=void 0!==Ea;Z?X[Y]=Ea:X[Y]?X=X[Y]:X=X[Y]={}};; return this._.apply(null,arguments);}.apply({navigator:typeof window!=undefined?window.navigator:null,document:typeof window!=undefined?window.document:null}, arguments);}