1 2 Previous Next 21 Replies Latest reply on Jun 17, 2008 10:44 AM by bgregory

    JavascriptTimeoutException

      I keep getting JavascriptTimeoutException for every test that I run with the new HtmlUnit version of JSFUnit. Some of my pages my take a little while to load (>10 seconds). Is there a way to set this timeout value?

      Stepping through the code it appears as though the next page is already loaded (or loading) by the time waitForJavascript() is called.

      Brian

        • 1. Re: JavascriptTimeoutException
          ssilvert

           

          "bgregory" wrote:
          Is there a way to set this timeout value?

          Yup. Try:
          JSFClientSession.setJavascriptTimeout()

          Stan

          • 2. Re: JavascriptTimeoutException

            Ok, I've set the javascript timeout to 30 seconds and I still get a timeout. Its a simple form and the click() is on an h:commandButton with a hard-coded action. Normal use of the webapp takes no more than 2 seconds to navigate.

            It appears to lock in the joinAll() call on the first thread - don't really understand this code yet - but working on it.

            Brian

            • 3. Re: JavascriptTimeoutException

              I tried a simple example and apparently the rich:pickList control is to blame.

              This simple form will do it:

              <h:form>
               <h:messages styleClass="formError"/>
               <h:panelGrid columns="2">
               <h:outputText value="F1:"/>
               <h:inputText id="f1Input" value="#{backingBean.value}" required="true"/>
               <h:outputText value="F2:"/>
               <rich:pickList id="missionPickList" value="#{backingBean.selected}">
               <f:selectItems value="#{backingBean.items}"/>
               </rich:pickList>
               </h:panelGrid>
               <h:panelGrid style="text-align: center" styleClass="centeredTable">
               <h:panelGroup>
               <h:commandButton id="addButton" value="Add" action="#{backingBean.doAction}"/>
               <rich:spacer width="5"/>
               <h:commandButton id="cancelButton" value="Cancel" immediate="true" action="#{backingBean.doCancel}"/>
               </h:panelGroup>
              </h:panelGrid>
              
              </h:form>
              


              • 4. Re: JavascriptTimeoutException
                ssilvert

                OK. I'll write a test for it.

                Can you post your JSFUnit code? I'd like to see what you are clicking.

                Stan

                • 5. Re: JavascriptTimeoutException

                  Either of the buttons will do it:

                   public void testBasicNav() throws MalformedURLException, IOException, SAXException {
                   JSFSession jsfSession = new JSFSession("/form.faces");
                   JSFClientSession client = jsfSession.getJSFClientSession();
                   JSFServerSession server = jsfSession.getJSFServerSession();
                  
                   client.click("addButton");
                   }
                  


                  • 6. Re: JavascriptTimeoutException

                    Here is the backingBean:

                    public class BackingBean {
                    
                     public List<SelectItem> getItems() {
                     List<SelectItem> list = new ArrayList<SelectItem>();
                     list.add(new SelectItem("One"));
                     list.add(new SelectItem("Two"));
                     list.add(new SelectItem("Three"));
                     list.add(new SelectItem("Four"));
                     list.add(new SelectItem("Five"));
                     return list;
                     }
                    
                     private String value;
                     public String getValue() {
                     return value;
                     }
                     public void setValue(String value) {
                     this.value = value;
                     }
                    
                     private List<String> selected = new ArrayList<String>();
                     public List<String> getSelected() {
                     return selected;
                     }
                     public void setSelected(List<String> selected) {
                     this.selected = selected;
                     }
                    
                     public String doAction() {
                     return null;
                     }
                    
                     public String doCancel() {
                     return null;
                     }
                    }
                    


                    • 7. Re: JavascriptTimeoutException

                      Ok, I'm not really sure whats going on now. I have another form page that does not contain a picklist, but has an input, a textarea, and a radio. The JTE happens when I attempt to set the first text field w/ setValue(). This field doesn't have any javascript assigned to it as far as I can tell.

                      • 8. Re: JavascriptTimeoutException

                        Something else I've come across: When attempting to setValue() on a textarea you get the following exception:

                        com.gargoylesoftware.htmlunit.html.HtmlTextArea
                        
                        java.lang.ClassCastException: com.gargoylesoftware.htmlunit.html.HtmlTextArea
                        at org.jboss.jsfunit.jsfsession.JSFClientSession.setValue(JSFClientSession.java:117)
                        
                        


                        • 9. Re: JavascriptTimeoutException

                          It appears that the <a4j:poll> control can cause the JTE also, if the polling interval is large.

                          • 10. Re: JavascriptTimeoutException
                            ssilvert

                             

                            "bgregory" wrote:
                            It appears that the <a4j:poll> control can cause the JTE also, if the polling interval is large.

                            That might explain it. I haven't been able to reproduce on my end, but I'm not using <a4j:poll>. That would make sense because HtmlUnit is probably doing a Thread.join() on the polling thread, and the polling thread never ends.

                            I'll look at this and the CCE as well.

                            Stan

                            • 11. Re: JavascriptTimeoutException

                              So you haven't been able to reproduce it with just the picklist?

                              • 12. Re: JavascriptTimeoutException

                                BTW, Which version of richfaces are you using?

                                • 13. Re: JavascriptTimeoutException
                                  ssilvert

                                  I'm using 3.2.0. I'm running against the RichFaces demo app.

                                  Before, I thought you were "clicking" on the picklist component itself and I got a bit sidetracked figuring out how to click each of the buttons inside the control.

                                  I won't be able to work on this any more until Sunday afternoon or evening.

                                  Stan

                                  • 14. Re: JavascriptTimeoutException

                                    Actually I wasn't expecting any responses until Monday, so thanks. :)

                                    1 2 Previous Next