From pieter.kuijpers at luminis.nl Mon Aug 13 03:36:21 2007 Content-Type: multipart/mixed; boundary="===============0002298711957184856==" MIME-Version: 1.0 From: pieter.kuijpers at luminis.nl To: jsfunit-dev at lists.jboss.org Subject: Re: [jsfunit-dev] ClientFacade.clickLink not working for h:commandLink Date: Mon, 13 Aug 2007 09:36:20 +0200 Message-ID: <52620.192.168.1.71.1186990580.webmail@192.168.1.71> --===============0002298711957184856== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Stan, ClickCommandLink works for me now. Thanks! Regards, Pieter. -----Original Message----- From: Stan Silvert Sent: Thu, August 9, 2007 5:18 pm To: Pieter Kuijpers Cc: jsfunit-dev(a)lists.jboss.org Subject: Re: [jsfunit-dev] ClientFacade.clickLink not working for h:command= Link Pieter, I've committed a fix for commandLink. It has been tested on MyFaces = 1.1.4, MyFaces 1.1.5, and JSF RI 1.2_04_P02 (the one that ships with = JBoss 4.2). There is a new method in ClientFacade called clickCommandLink(). You = will need to use that instead of clickLink(). Can you try it out and let us know if it works for you? Thanks, Stan Pieter Kuijpers wrote: > Hi Stan, > = > Thanks for the quick response. I've tried commenting out the two lines = > you indicated, but still no luck. HttpUnit doesn't seem to be able to = > cope with the JavaScript that is generated for the commandLink. The = > error I get is: > = > com.meterware.httpunit.ScriptException: Event 'if(typeof jsfcljs =3D=3D = > 'function'){jsfcljs(document.forms['form'],'form:link,form:link','');}ret= urn = > false' failed: TypeError: undefined is not a function. (httpunit; ) > at = > com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScrip= tException(JavaScript.java:202) > at = > com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEven= t(JavaScript.java:175) > at = > com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDel= egate.java:56) > at = > com.meterware.httpunit.WebRequestSource.submitRequest(WebRequestSource.ja= va:232) > at com.meterware.httpunit.WebLink.click(WebLink.java:98) > = > I'm using JBoss 4.2.0GA, that in turn uses the JSF reference = > implementation, so that may explain why this fix is working for you but = > not for me. > = > The HTML/Javascript that is generated for link.jsp is: > = > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > = > > > > = > Link test > > = > >
name=3D"j_id_jsp_918822224_1" > method=3D"post" action=3D"/JsfTest/link.faces" = > enctype=3D"application/x-www-form-urlencoded"> > value=3D"j_id_jsp_918822224_1" /> > > onclick=3D"if(typeof jsfcljs =3D=3D = > 'function'){jsfcljs(document.forms['j_id_jsp_918822224_1'],'j_id_jsp_9188= 22224_1:link,j_id_jsp_918822224_1:link','');}return = > false" name=3D"j_id_jsp_918822224_1:link">click me > id=3D"javax.faces.ViewState" value=3D"j_id1:j_id2" /> >
> > > = > My JavaScript knowledge is not very deep, so I'm having trouble = > understanding the error message from HttpUnit. > = > Regards, > Pieter. > = > = > Op 8-aug-2007, om 2:41 heeft Stan Silvert het volgende geschreven: > = >> Hi Pieter, >> >> The fix is taking a little longer than I expected. If you comment out = >> two lines of code in WebConversationFactory then the = >> client.clickLink() on a commandLink will work (at least with MyFaces = >> 1.1). The two lines are: >> >> HTMLParserFactory.useJTidyParser(); >> HttpUnitOptions.setScriptingEnabled(false); >> >> The problem is, that will break AJAX support. So I'm not sure what = >> the final solution will be. >> >> Stan >> >> Pieter Kuijpers wrote: >>> I'm trying to test a commandLink in a page with = >>> ClientFacade.clickLink, but this does not seem to be working. >>> link.jsp: >>> >>> <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> >>> <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> >>> >>> >>> >>> Link test >>> >>> >>> >>> >>> >>> >>> >>> >>> target.jsp: >>> >>> >>> >>> Link test successful >>> >>> >>> Success. >>> >>> >>> Test code: >>> public class LinkTest extends TestCase { >>> public void testClickLink() throws Exception { >>> ClientFacade client =3D new ClientFacade("/link.faces"); >>> client.clickLink("link"); >>> assertEquals("Link test successful", = >>> client.getWebResponse().getTitle()); >>> } >>> } >>> The HTML that is returned using client.getWebResponse().getText is = >>> that of link.jsp. When I try the same test by hand, it is working OK. >>> How is this supposed to work? >>> Thanks, >>> Pieter Kuijpers. >>> ------------------------------------------------------------------------ >>> _______________________________________________ >>> jsfunit-dev mailing list >>> jsfunit-dev(a)lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/jsfunit-dev >> > = > -- > = > Pieter Kuijpers > Senior software engineer *luminis*=C2=AE > ------------------------------------------------- > 06 174 185 34 > pieter.kuijpers(a)luminis.nl > www.luminis.nl > ------------------------------------------------- > = > = > = --===============0002298711957184856==--