如何在Selenium 2 WebDriver TestNg测试中设置日志级别



我正在用Java实现一组Selenium WebDriver测试,我创建了以下ant构建文件来运行所有测试:

<project name="selenium" default="test" basedir=".">
 <path id="cp">
   <pathelement location="lib/testng-6.3.1.jar"/>
   <pathelement location="lib/jcommander-1.13.jar"/>
   <pathelement location="lib/bsh-1.3.0.jar"/>
   <pathelement location="lib/selenium-java-2.15.0.jar"/>
   <pathelement location="lib/selenium-server-standalone-2.14.0.jar"/>
   <pathelement location="bin"/>
 </path>
 <taskdef name="testng" classpathref="cp"
          classname="org.testng.TestNGAntTask" />
 <target name="test" depends="compile">
   <testng classpathref="cp" haltOnFailure="false">
     <classfileset dir="bin" includes="org/rnig/selenium/**/*Test.class"/>     
   </testng>
 </target>
 <target name="clean">
   <delete dir="bin" />
 </target>
 <target name="compile" depends="clean">
   <mkdir dir="bin" />
   <javac srcdir="src" destdir="bin" classpathref="cp" includeantruntime="no" />
 </target>
</project>

当我在命令行中执行"ant test"时,一切正常,但我在屏幕上得到大量的日志消息:

(...)
   [testng] Dec 14, 2011 4:17:13 PM org.openqa.selenium.remote.RemoteWebDriver execute
   [testng] INFO: Executing: [1323679961495, executeScript {"script":"return (function() { return (function(){return function(){function f(a){throw a;}var i=void 0,j=null,l,n=this;nfunction aa(a){var b=typeof a;if(b=="object")if(a){if(a instanceof Array)return"array";else if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(c=="[object Window]")return"object";if(c=="[object Array]"||typeof a.length=="number"&&typeof a.splice!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("splice"))return"array";if(c=="[object Function]"||typeof a.call!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("call"))return"function"}else return"null";nelse if(b=="function"&&typeof a.call=="undefined")return"object";return b}function o(a){return typeof a=="string"}function p(a){return aa(a)=="function"}function ba(a){a=aa(a);return a=="object"||a=="array"||a=="function"}var ca="closure_uid_"+Math.floor(Math.random()*2147483648).toString(36),da=0;function ea(a){var b=Array.prototype.slice.call(arguments,1);return function(){var c=Array.prototype.slice.call(arguments);c.unshift.apply(c,b);return a.apply(this,c)}}var fa=Date.now||function(){return+new Date};nfunction q(a,b){function c(){}c.prototype=b.prototype;a.H=b.prototype;a.prototype=new c};function ga(a,b){var c=a.length-b.length;return c>=0&&a.indexOf(b,c)==c}function ha(a){for(var b=1;b<arguments.length;b++)var c=String(arguments[b]).replace(/\$/g,"$$$$"),a=a.replace(/\%s/,c);return a}function s(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")}function ia(a,b){if(a<b)return-1;else if(a>b)return 1;return 0}var ja={};function ka(a){return ja[a]||(ja[a]=String(a).replace(/\-([a-z])/g,function(a,c){return c.toUpperCase()}))};var la={},t,ma,u,na;function oa(){return n.navigator?n.navigator.userAgent:j}na=u=ma=t=!1;var v;if(v=oa()){var pa=n.navigator;t=v.indexOf("Opera")==0;ma=!t&&v.indexOf("MSIE")!=-1;u=!t&&v.indexOf("WebKit")!=-1;na=!t&&!u&&pa.product=="Gecko"}var qa=t,w=ma,x=na,y=u,ra=n.navigator,sa=(ra&&ra.platform||"").indexOf("Mac")!=-1,z;na:{var ta="",A;if(qa&&n.opera)var ua=n.opera.version,ta=typeof ua=="function"?ua():ua;else if(x?A=/rv\:([^\);]+)(\)|;)/:w?A=/MSIE\s+([^\);]+)(\)|;)/:y&&(A=/WebKit\/(\S+)/),A)var va=A.exec(oa()),ta=va?va[1]:"";if(w){var wa,xa=n.document;wa=xa?xa.documentMode:i;if(wa>parseFloat(ta)){z=String(wa);break a}}z=ta}var ya={};nfunction B(a){var b;if(!(b=ya[a])){b=0;for(var c=s(String(z)).split("."),d=s(String(a)).split("."),e=Math.max(c.length,d.length),h=0;b==0&&h<e;h++){var g=c[h]||"",k=d[h]||"",m=RegExp("(\\d*)(\\D*)","g"),r=RegExp("(\\d*)(\\D*)","g");do{var P=m.exec(g)||["","",""],Q=r.exec(k)||["","",""];if(P[0].length==0&&Q[0].length==0)break;b=ia(P[1].length==0?0:parseInt(P[1],10),Q[1].length==0?0:parseInt(Q[1],10))||ia(P[2].length==0,Q[2].length==0)||ia(P[2],Q[2])}while(b==0)}b=ya[a]=b>=0}return b}var za={};nfunction Aa(){return za[9]||(za[9]=w&&document.documentMode&&document.documentMode>=9)};var C=window;function D(a){this.stack=Error().stack||"";if(a)this.message=String(a)}q(D,Error);D.prototype.name="CustomError";function E(a,b){D.call(this,b);this.code=a;this.name=Ba[a]||Ba[13]}q(E,D);nvar Ba,Ca={NoSuchElementError:7,NoSuchFrameError:8,UnknownCommandError:9,StaleElementReferenceError:10,ElementNotVisibleError:11,InvalidElementStateError:12,UnknownError:13,ElementNotSelectableError:15,XPathLookupError:19,NoSuchWindowError:23,InvalidCookieDomainError:24,UnableToSetCookieError:25,ModalDialogOpenedError:26,NoModalDialogOpenError:27,ScriptTimeoutError:28,InvalidSelectorError:32,SqlDatabaseError:33,MoveTargetOutOfBoundsError:34},Da={},Ea;for(Ea in Ca)Da[Ca[Ea]]=Ea;Ba=Da;nE.prototype.toString=function(){return"["+this.name+"] "+this.message};function Fa(a,b){b.unshift(a);D.call(this,ha.apply(j,b));b.shift();this.J=a}q(Fa,D);Fa.prototype.name="AssertionError";function F(a,b){if(o(a)){if(!o(b)||b.length!=1)return-1;return a.indexOf(b,0)}for(var c=0;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1}function Ga(a,b){for(var c=a.length,d=o(a)?a.split(""):a,e=0;e<c;e++)e in d&&b.call(i,d[e],e,a)}function G(a,b){for(var c=a.length,d=[],e=0,h=o(a)?a.split(""):a,g=0;g<c;g++)if(g in h){var k=h[g];b.call(i,k,g,a)&&(d[e++]=k)}return d}function Ha(a,b){for(var c=a.length,d=o(a)?a.split(""):a,e=0;e<c;e++)if(e in d&&b.call(i,d[e],e,a))return!0;return!1}nfunction Ia(a,b){var c;a:{c=a.length;for(var d=o(a)?a.split(""):a,e=0;e<c;e++)if(e in d&&b.call(i,d[e],e,a)){c=e;break a}c=-1}return c<0?j:o(a)?a.charAt(c):a[c]};var Ja;!w||Aa();!x&&!w||w&&Aa()||x&&B("1.9.1");w&&B("9");function Ka(a,b){this.width=a;this.height=b}Ka.prototype.toString=function(){return"("+this.width+" x "+this.height+")"};Ka.prototype.floor=function(){this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};var La=3;function H(a){return a?new Ma(I(a)):Ja||(Ja=new Ma)}nfunction Na(a,b,c,d){a=d||a;b=b&&b!="*"?b.toUpperCase():"";if(a.querySelectorAll&&a.querySelector&&(!y||document.compatMode=="CSS1Compat"||B("528"))&&(b||c))return a.querySelectorAll(b+(c?"."+c:""));if(c&&a.getElementsByClassName)if(a=a.getElementsByClassName(c),b){for(var d={},e=0,h=0,g;g=a[h];h++)b==g.nodeName&&(d[e++]=g);d.length=e;return d}else return a;a=a.getElementsByTagName(b||"*");if(c){d={};for(h=e=0;g=a[h];h++)b=g.className,typeof b.split=="function"&&F(b.split(/\s+/),c)>=0&&(d[e++]=g);nd.length=e;return d}else return a}function Oa(a,b){if(a.contains&&b.nodeType==1)return a==b||a.contains(b);if(typeof a.compareDocumentPosition!="undefined")return a==b||Boolean(a.compareDocumentPosition(b)&16);for(;b&&a!=b;)b=b.parentNode;return b==a}function I(a){return a.nodeType==9?a:a.ownerDocument||a.document}function Pa(a,b){var c=[];return Qa(a,b,c,!0)?c[0]:i}nfunction Qa(a,b,c,d){if(a!=j)for(a=a.firstChild;a;){if(b(a)&&(c.push(a),d))return!0;if(Qa(a,b,c,d))return!0;a=a.nextSibling}return!1}function Ra(a,b){for(var a=a.parentNode,c=0;a;){if(b(a))return a;a=a.parentNode;c++}return j}function Ma(a){this.i=a||n.document||document}function J(a,b,c,d){return Na(a.i,b,c,d)}Ma.prototype.contains=Oa;var K={};K.s=function(){var a={L:"http://www.w3.org/2000/svg"};return function(b){return a[b]||j}}();K.k=function(a,b,c){var d=I(a);if(!d.implementation.hasFeature("XPath","3.0"))return j;var e=d.createNSResolver?d.createNSResolver(d.documentElement):K.s;return d.evaluate(b,a,e,c,j)};K.m=function(a){return"NS_ERROR_ILLEGAL_VALUE"!=a.name};nK.b=function(a,b){var c=function(b,c){var h=I(b);try{if(b.selectSingleNode)return h.setProperty&&h.setProperty("SelectionLanguage","XPath"),b.selectSingleNode(c);var g=K.k(b,c,9);return g?g.singleNodeValue:j}catch(k){return K.m(k)&&f(new E(32,"Unable to locate an element with the xpath expression "+a+" because of the following error:\n"+k)),j}}(b,a);if(!c)return j;c.nodeType!=1&&f(new E(32,'The result of the xpath expression "'+a+'" is: '+c+". It should be an element."));return c};nK.e=function(a,b){var c=function(a,b){var c=I(a),g;try{if(a.selectNodes)return c.setProperty&&c.setProperty("SelectionLanguage","XPath"),a.selectNodes(b);g=K.k(a,b,7)}catch(k){K.m(k)&&f(new E(32,"Unable to locate elements with the xpath expression "+b+" because of the following error:\n"+k))}c=[];if(g)for(var m=g.snapshotLength,r=0;r<m;++r)c.push(g.snapshotItem(r));return c}(b,a);Ga(c,function(b){b.nodeType!=1&&f(new E(32,'The result of the xpath expression "'+a+'" is: '+b+". It should be an element."))});nreturn c};var Sa="StopIteration"in n?n.StopIteration:Error("StopIteration");function Ta(){}Ta.prototype.next=function(){f(Sa)};function L(a,b,c,d,e){this.a=!!b;a&&M(this,a,d);this.f=e!=i?e:this.d||0;this.a&&(this.f*=-1);this.v=!c}q(L,Ta);l=L.prototype;l.c=j;l.d=0;l.q=!1;function M(a,b,c){if(a.c=b)a.d=typeof c=="number"?c:a.c.nodeType!=1?0:a.a?-1:1}nl.next=function(){var a;if(this.q){(!this.c||this.v&&this.f==0)&&f(Sa);a=this.c;var b=this.a?-1:1;if(this.d==b){var c=this.a?a.lastChild:a.firstChild;c?M(this,c):M(this,a,b*-1)}else(c=this.a?a.previousSibling:a.nextSibling)?M(this,c):M(this,a.parentNode,b*-1);this.f+=this.d*(this.a?-1:1)}else this.q=!0;(a=this.c)||f(Sa);return a};nl.splice=function(){var a=this.c,b=this.a?1:-1;if(this.d==b)this.d=b*-1,this.f+=this.d*(this.a?-1:1);this.a=!this.a;L.prototype.next.call(this);this.a=!this.a;for(var b=arguments[0],c=aa(b),b=c=="array"||c=="object"&&typeof b.length=="number"?arguments[0]:arguments,c=b.length-1;c>=0;c--)a.parentNode&&a.parentNode.insertBefore(b[c],a.nextSibling);a&&a.parentNode&&a.parentNode.removeChild(a)};function Ua(a,b,c,d){L.call(this,a,b,c,j,d)}q(Ua,L);Ua.prototype.next=function(){do Ua.H.next.call(this);while(this.d==-1);return this.c};function Va(a,b){var c=I(a);if(c.defaultView&&c.defaultView.getComputedStyle&&(c=c.defaultView.getComputedStyle(a,j)))return c[b]||c.getPropertyValue(b);return""}function Wa(a){var b=a.offsetWidth,c=a.offsetHeight,d=y&&!b&&!c;if((b===i||d)&&a.getBoundingClientRect){b=a.getBoundingClientRect();if(w)a=a.ownerDocument,b.left-=a.documentElement.clientLeft+a.body.clientLeft,b.top-=a.documentElement.clientTop+a.body.clientTop;return new Ka(b.right-b.left,b.bottom-b.top)}return new Ka(b,c)};function N(a,b){return!!a&&a.nodeType==1&&(!b||a.tagName.toUpperCase()==b)}var Xa={"class":"className",readonly:"readOnly"},Ya=["checked","disabled","draggable","hidden"];function Za(a,b){var c=Xa[b]||b,d=a[c];if(d===i&&F(Ya,c)>=0)return!1;return d}nvar $a=["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"];nfunction O(a,b){if(8==a.nodeType)return j;b=b.toLowerCase();if(b=="style"){var c=s(a.style.cssText).toLowerCase();return c.charAt(c.length-1)==";"?c:c+";"}c=a.getAttributeNode(b);w&&!c&&B(8)&&F($a,b)>=0&&(c=a[b]);if(!c)return j;if(F($a,b)>=0)return w&&c.value=="false"?j:"true";return c.specified?c.value:j}function ab(a){for(a=a.parentNode;a&&a.nodeType!=1&&a.nodeType!=9&&a.nodeType!=11;)a=a.parentNode;return N(a)?a:j}function R(a,b){b=ka(b);return Va(a,b)||bb(a,b)}nfunction bb(a,b){var c=a.currentStyle||a.style,d=c[b];d===i&&p(c.getPropertyValue)&&(d=c.getPropertyValue(b));if(d!="inherit")return d!==i?d:j;return(c=ab(a))?bb(c,b):j}nfunction cb(a){if(p(a.getBBox))return a.getBBox();var b;if((Va(a,"display")||(a.currentStyle?a.currentStyle.display:j)||a.style&&a.style.display)!="none")b=Wa(a);else{b=a.style;var c=b.display,d=b.visibility,e=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";a=Wa(a);b.display=c;b.position=e;b.visibility=d;b=a}return b}nfunction db(a,b){function c(a){if(R(a,"display")=="none")return!1;a=ab(a);return!a||c(a)}function d(a){var b=cb(a);if(b.height>0&&b.width>0)return!0;return Ha(a.childNodes,function(a){return a.nodeType==La||N(a)&&d(a)})}N(a)||f(Error("Argument to isShown must be of type Element"));if(N(a,"OPTION")||N(a,"OPTGROUP")){var e=Ra(a,function(a){return N(a,"SELECT")});return!!e&&db(e,!0)}if(N(a,"MAP")){if(!a.name)return!1;e=I(a);e=e.evaluate?K.b('/descendant::*[@usemap = "#'+a.name+'"]',e):Pa(e,function(b){return N(b)&&nO(b,"usemap")=="#"+a.name});return!!e&&db(e,b)}if(N(a,"AREA"))return e=Ra(a,function(a){return N(a,"MAP")}),!!e&&db(e,b);if(N(a,"INPUT")&&a.type.toLowerCase()=="hidden")return!1;if(R(a,"visibility")=="hidden")return!1;if(!c(a))return!1;if(!b&&eb(a)==0)return!1;if(!d(a))return!1;return!0}function fb(a){return a.replace(/^[^\S\xa0]+|[^\S\xa0]+$/g,"")}nfunction gb(a){var b=[];hb(a,b);for(var c=b,a=c.length,b=Array(a),c=o(c)?c.split(""):c,d=0;d<a;d++)d in c&&(b[d]=fb.call(i,c[d]));return fb(b.join("\n")).replace(/\xa0/g," ")}nfunction hb(a,b){if(N(a,"BR"))b.push("");else{var c=N(a,"TD"),d=R(a,"display"),e=!c&&!(F(ib,d)>=0);e&&!/^[\s\xa0]*$/.test(b[b.length-1]||"")&&b.push("");var h=db(a),g=j,k=j;h&&(g=R(a,"white-space"),k=R(a,"text-transform"));Ga(a.childNodes,function(a){a.nodeType==La&&h?jb(a,b,g,k):N(a)&&hb(a,b)});var m=b[b.length-1]||"";if((c||d=="table-cell")&&m&&!ga(m," "))b[b.length-1]+=" ";e&&!/^[\s\xa0]*$/.test(m)&&b.push("")}}var ib=["inline","inline-block","inline-table","none","table-cell","table-column","table-column-group"];nfunction jb(a,b,c,d){a=a.nodeValue.replace(/\u200b/g,"");a=a.replace(/(\r\n|\r|\n)/g,"\n");if(c=="normal"||c=="nowrap")a=a.replace(/\n/g," ");a=c=="pre"||c=="pre-wrap"?a.replace(/[ \f\t\v\u2028\u2029]/g,"\u00a0"):a.replace(/[\ \f\t\v\u2028\u2029]+/g," ");d=="capitalize"?a=a.replace(/(^|\s)(\S)/g,function(a,b,c){return b+c.toUpperCase()}):d=="uppercase"?a=a.toUpperCase():d=="lowercase"&&(a=a.toLowerCase());c=b.pop()||"";ga(c," ")&&a.lastIndexOf(" ",0)==0&&(a=a.substr(1));b.push(c+a)}nfunction eb(a){if(w){if(R(a,"position")=="relative")return 1;a=R(a,"filter");return(a=a.match(/^alpha\(opacity=(\d*)\)/)||a.match(/^progid:DXImageTransform.Microsoft.Alpha\(Opacity=(\d*)\)/))?Number(a[1])/100:1}else return kb(a)}function kb(a){var b=1,c=R(a,"opacity");c&&(b=Number(c));(a=ab(a))&&(b*=kb(a));return b};function S(a){D.call(this,a)}q(S,D);!w||Aa();!w||Aa();w&&B("8");!y||B("528");x&&B("1.9b")||w&&B("8")||qa&&B("9.5")||y&&B("528");!x||B("8");function lb(){mb&&(this[ca]||(this[ca]=++da))}var mb=!1;function T(a,b){lb.call(this);this.type=a;this.currentTarget=this.target=b}q(T,lb);T.prototype.D=!1;T.prototype.F=!0;function nb(a){nb[" "](a);return a}nb[" "]=function(){};function ob(a,b){if(a){var c=this.type=a.type;T.call(this,c);this.target=a.target||a.srcElement;this.currentTarget=b;var d=a.relatedTarget;if(d){if(x){var e;a:{try{nb(d.nodeName);e=!0;break a}catch(h){}e=!1}e||(d=j)}}else if(c=="mouseover")d=a.fromElement;else if(c=="mouseout")d=a.toElement;this.relatedTarget=d;this.offsetX=a.offsetX!==i?a.offsetX:a.layerX;this.offsetY=a.offsetY!==i?a.offsetY:a.layerY;this.clientX=a.clientX!==i?a.clientX:a.pageX;this.clientY=a.clientY!==i?a.clientY:a.pageY;this.screenX=na.screenX||0;this.screenY=a.screenY||0;this.button=a.button;this.keyCode=a.keyCode||0;this.charCode=a.charCode||(c=="keypress"?a.keyCode:0);this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.C=sa?a.metaKey:a.ctrlKey;this.state=a.state;this.w=a;delete this.F;delete this.D}}q(ob,T);l=ob.prototype;l.target=j;l.relatedTarget=j;l.offsetX=0;l.offsetY=0;l.clientX=0;l.clientY=0;l.screenX=0;l.screenY=0;l.button=0;l.keyCode=0;l.charCode=0;l.ctrlKey=!1;nl.altKey=!1;l.shiftKey=!1;l.metaKey=!1;l.C=!1;l.w=j;var U={g:function(a){return!(!a.querySelectorAll||!a.querySelector)}};U.b=function(a,b){a||f(Error("No class name specified"));a=s(a);a.split(/\s+/).length>1&&f(Error("Compound class names not permitted"));if(U.g(b))return b.querySelector("."+a.replace(/\./g,"\\."))||j;var c=J(H(b),"*",a,b);return c.length?c[0]:j};nU.e=function(a,b){a||f(Error("No class name specified"));a=s(a);a.split(/\s+/).length>1&&f(Error("Compound class names not permitted"));if(U.g(b))return b.querySelectorAll("."+a.replace(/\./g,"\\."));return J(H(b),"*",a,b)};var V={};V.b=function(a,b){!p(b.querySelector)&&w&&B(8)&&!ba(b.querySelector)&&f(Error("CSS selection is not supported"));a||f(Error("No selector specified"));V.h(a)&&f(Error("Compound selectors not permitted"));var a=s(a),c=b.querySelector(a);return c&&c.nodeType==1?c:j};V.e=function(a,b){!p(b.querySelectorAll)&&w&&B(8)&&!ba(b.querySelector)&&f(Error("CSS selection is not supported"));a||f(Error("No selector specified"));V.h(a)&&f(Error("Compound selectors not permitted"));a=s(a);return b.querySelectorAll(a)};nV.h=function(a){return a.split(/(,)(?=(?:[^']|'[^']*')*$)/).length>1&&a.split(/(,)(?=(?:[^"]|"[^"]*")*$)/).length>1};var W={},pb={};W.p=function(a,b,c){b=J(H(b),"A",j,b);return Ia(b,function(b){b=gb(b);return c&&b.indexOf(a)!=-1||b==a})};W.n=function(a,b,c){b=J(H(b),"A",j,b);return G(b,function(b){b=gb(b);return c&&b.indexOf(a)!=-1||b==a})};W.b=function(a,b){return W.p(a,b,!1)};W.e=function(a,b){return W.n(a,b,!1)};pb.b=function(a,b){return W.p(a,b,!0)};pb.e=function(a,b){return W.n(a,b,!0)};var qb={b:function(a,b){return b.getElementsByTagName(a)[0]||j},e:function(a,b){return b.getElementsByTagName(a)}};var rb={className:U,"class name":U,css:V,"css selector":V,id:{b:function(a,b){var c=H(b),d=o(a)?c.i.getElementById(a):a;if(!d)return j;if(O(d,"id")==a&&Oa(b,d))return d;c=J(c,"*");return Ia(c,function(c){return O(c,"id")==a&&Oa(b,c)})},e:function(a,b){var c=J(H(b),"*",j,b);return G(c,function(b){return O(b,"id")==a})}},linkText:W,"link text":W,name:{b:function(a,b){var c=J(H(b),"*",j,b);return Ia(c,function(b){return O(b,"name")==a})},e:function(a,b){var c=J(H(b),"*",j,b);return G(c,function(b){return O(b,n"name")==a})}},partialLinkText:pb,"partial link text":pb,tagName:qb,"tag name":qb,xpath:K};function sb(a,b){var c;a:{for(c in a)if(a.hasOwnProperty(c))break a;c=j}if(c){var d=rb[c];if(d&&p(d.b))return d.b(a[c],b||C.document)}f(Error("Unsupported locator strategy: "+c))};var tb={index:function(a,b){a=Number(a);(isNaN(a)||a<0)&&f(new S("Illegal Index: "+a));b.length<=a&&f(new S("Index out of range: "+a));return[b[a]]},name:function(a,b){return G(b,function(b){return Za(b,"name")==a})},value:function(a,b){return G(b,function(b){return Za(b,"value")===a})}};var X={};X.A=function(a,b){if(a.lastIndexOf("//",0)==0)return X.r(a,b);if(a.lastIndexOf("document.",0)==0)return X.j(a);return X.l(a,b)};X.t=function(a,b){return ub(b||I(C),function(b){return b.alt==a})};X.u=function(a,b){return ub(b||I(C),function(b){return b.className==a})};X.j=function(a){var b=j;try{b=eval(a)}catch(c){return j}return b?b:j};X.z=function(a,b){return sb({id:a},b)};X.l=function(a,b){return X.id(a,b)||X.name(a,b)};nX.B=function(a,b){var c=b||I(C);H(c);var d=Na(document,"*",j,c),c=a.split(" ");for(c[0]="name="+c[0];c.length;){var e=c.shift(),h="value",g=e.match(/^([A-Za-z]+)=(.+)/);g&&(h=g[1].toLowerCase(),e=g[2]);(g=tb[h])||f(new S("Unrecognised element-filter type: '"+h+"'"));d=g(e,d)}return d.length>0?d[0]:j};nX.G=function(a,b){try{var c;a:{var d;d=decodeURIComponent(a);var e=b||document,h,g=e||document,k=g.$wdc_;if(!k)k=g.$wdc_={},k.o=fa();if(!k.o)k.o=fa();h=k;d in h||f(new E(10,"Element does not exist in cache"));var m=h[d];if("document"in m)m.closed&&(delete h[d],f(new E(23,"Window has been closed."))),c=m;else{for(g=m;g;){if(g==e.documentElement){c=m;break a}g=g.parentNode}delete h[d];f(new E(10,"Element is no longer attached to the DOM"))}}return c}catch(r){return j}};nX.r=function(a,b){var c=ga(a,"/"),d={xpath:a};try{var e=sb(d,b);if(e||!c)return e}catch(h){c||f(h)}d={xpath:a.substring(0,a.length-1)};return sb(d,b)};X.alt=X.t;X["class"]=X.u;X.dom=X.j;X.id=X.z;X.identifier=X.l;X.implicit=X.A;X.name=X.B;X.stored=X.G;X.xpath=X.r;function vb(a,b,c,d){var e=X[a];e||f(new S("Unrecognised locator type: '"+a+"'"));c=e.call(j,b,c);if(c!=j)return c;if(!d)return j;for(e=0;e<d.frames.length;e++){var h;try{h=d.frames[e].document}catch(g){}if(h&&(c=vb(a,b,h,d.frames[e]),c!=j))return c}return j}function ub(a,b){for(var c=a.childNodes.length,d=0;d<c;d++){var e=a.childNodes[d];if(e.nodeType==1){if(b(e))return e;if(e=ub(e,b))return e}}return j};function wb(a,b){return RegExp(a).test(b)}function xb(a,b){return RegExp(a,"i").text(b)}function yb(a){a=a.replace(/([.^$+(){}\[\]\\|])/g,"\\$1");a=a.replace(/\?/g,"(.|[\r\n])");return a=a.replace(/\*/g,"(.|[\r\n])*")}var zb={exact:function(a,b){return b.indexOf(a)!=-1},glob:function(a,b){return RegExp("^"+yb(a)+"$").test(b)},globcontains:function(a,b){return RegExp(yb(a)).test(b)},regex:wb,regexi:xb,regexpi:xb,regexp:wb};function Ab(a,b){if(a.style&&(a.style.visibility=="hidden"||a.style.display=="none"))return"";var c;if(a.nodeType==La)return c=a.data,b||(c=c.replace(/\n|\r|\t/g," ")),c.replace(/&nbsp/," ");if(a.nodeType==1&&a.nodeName!="SCRIPT"){var d=b||a.tagName=="PRE";c="";for(var e=0;e<a.childNodes.length;e++){var h=a.childNodes.item(e);c+=Ab(h,d)}if(a.tagName=="P"||a.tagName=="BR"||a.tagName=="HR"||a.tagName=="DIV")c+="\n";return c.replace(/&nbsp/," ")}return""}nfunction Bb(a){if(o(a)){var b;b=a;var c=b.match(/^([A-Za-z]+)=.+/);c?(c=c[1].toLowerCase(),b={type:c,string:b.substring(c.length+1)}):(c={string:"",type:""},c.string=b,c.type=b.lastIndexOf("//",0)==0?"xpath":b.lastIndexOf("document.",0)==0?"dom":"identifier",b=c);c=C||C;b=vb(b.type,b.string,c.document,c);b=b!=j?b:j;b==j&&f(new S("Element "+a+" not found"));a=b}b="";if(x&&z>="1.8"||la.I||y||qa)b=Ab(a);else if(a.textContent)b=a.textContent;else if(a.innerText)b=a.innerText;b=b.replace(/\r\n|\r/g,"\n");na=b;if(!w)if(a=a.replace(/\ +/g," "),b=RegExp(String.fromCharCode(160),"g"),y)for(b=String.fromCharCode(160);a.indexOf(b)!=-1;)a=a.replace(b," ");else a=a.replace(b," ");b=a;return s(b)}nX.link=function(a,b){for(var c=(b||I(C)).getElementsByTagName("a"),d=0;d<c.length;d++){var e=c[d],h=Bb(e),g=a,k="glob",m=/^([a-zA-Z-]+):(.*)/.exec(g);if(m){var r=m[1],m=m[2];zb[r.toLowerCase()]&&(k=r.toLowerCase(),g=m)}(r=zb[k])||f(new S("Cannot find pattern matching strategy: "+k));k=="glob"?(g.indexOf("glob:")==0&&(g=g.substring(5)),r=zb.glob):k=="exact"&&g.indexOf("exact:")==0&&(g=g.substring(6));g=ea(r,g);g.K=k;if(g(h))return e}return j};var Y="_".split("."),Z=n;!(Y[0]in Z)&&Z.execScript&&Z.execScript("var "+Y[0]);for(var $;Y.length&&($=Y.shift());)!Y.length&&Bb!==i?Z[$]=Bb:Z=Z[$]?Z[$]:Z[$]={};; return this._.apply(null,arguments);}.apply({navigator:typeof window!='undefined'?window.navigator:null}, arguments);}n).apply(null, arguments);})(arguments[0]);","args":["//div[@class='errormessage'][1]"]}]
   [testng] Dec 14, 2011 4:17:13 PM org.openqa.selenium.remote.RemoteWebDriver execute
   [testng] INFO: Executing: [1323679961495, deleteAllCookies {}]
   [testng] Dec 14, 2011 4:17:13 PM org.openqa.selenium.remote.RemoteWebDriver execute
   [testng] INFO: Executing: [1323679961495, quit {}]

我假设INFO消息来自WebDriver库,但我不知道如何更改日志级别。什么好主意吗?

顺便说一句,我已经试过了:

LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.DRIVER, Level.OFF);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);
driver = new FirefoxDriver(capabilities);

:

Logger logger = Logger.getLogger("");
logger.setLevel(Level.WARNING);

没有运气,尽管后面的INFO消息停止在Eclipse控制台中打印。

UPDATE:在正确的地方设置标准java.util.logger logLevel为例如WARNING(如上所示),在我的情况下,在@BeforeClass方法中,解决了这个问题。

使用什么日志框架?我会提供自定义配置文件,而不是通过API设置它。我认为使用java.util.logging,我的选择是jul——over-slf4j + slf4j-api + logback-classic,然后在logback的配置文件中设置记录器和追加器。

通过以下链接:http://selenium-suresh.blogspot.in/2013/02/ant-generating-selenium-reports-using.html

Anand Palabhavi

相关内容

  • 没有找到相关文章

最新更新