From: Marc G. <mgu...@ya...> - 2005-02-04 08:43:32
|
Hi Jun, htmlunit can handle html code dynamically generated with document.write... to a certain extent (for example, document.write in the head currently make problems). In your example, if it works correctly, you should find the <script> elements in the td, as well as the generated content. What errors do you become? How do you test that the table cell only contains the <script....>? Marc. Jun Ma wrote: > > > Hi, there > > I am a new comer for HtmlUnit. The Web application I am testing > employs quite a lot Javascript code. It uses a Javascript code to > generate a tool bar. The HTML code looks like the attached one. > > The page has a table. This table has two rows. In the first row, > there are two HTML links. In the second row, there is tool bar. The > toolbar.Write() method dynamically generates a piece of HTML code, like: > <img src=..... onClick="......"... />. This code represents a button on > this tool bar. > > My question is that how I use HTMLUnit to access this javascript > generated HTML object. > > Via HTMLUnit, I can get the objects for the HTML Anchors defined in > the first row of this table. However, I can not get the Javascript > generated HTML objects. When I got the object of that Table cell, it > only contains "<script language="javascript"> > toolbarContainer.begin(); toolbar.write(); toolbarContainer.end(); > </script>", not the <img ....> objects I am expecting. > > Do you know how to use HTMLUnit to manipulate the HTML objects > dynamically generated by Javascript? > > Thanks a lot. > > > > Jun > > > > <table class="list" width="100%" border="0" cellspacing="0" > cellpadding="0" id="navHeadTable"> > > <tr class="panelTitlebar" style="background-image: > url('<html:rewrite page='<%= schema.getUrl(application, > "img.panel.titlebar") %>'/>');"> > > <td align="left"> > > <table cellpadding="0" cellspacing="0"> > > <tr> > > <td > class="panelText"><img id="navTitleImage" src='<html:rewrite page='<%= > schema.getUrl(application, "img.folder.regular") %>'/>' > > > align="middle" hspace="3" vspace="0" border="0" /></td> > > <td > id="navTitle" align="left" class="panelText" nowrap><fmt:message > key='main.nav.folders.title'/></td> > > </tr> > > </table> > > </td> > > <td align="right"> > > <table cellpadding="0" cellspacing="0"> > > <tr> > > <td class="panelText" > nowrap> > > <a > href="javascript:onBtnHideNavClick();" class="panelText" > title='<fmt:message key="main.nav.hide.tooltip"/>' > > > onMouseOver="panelButtonHover('navHideImg', collapseImgOver);" > onMouseOut="panelButtonHover('navHideImg', collapseImg);"> > > > <fmt:message key="main.panel.collapse"/> > > </a> > > </td><td> > > <a > href="javascript:onBtnHideNavClick();" class="panelText" > title='<fmt:message key="main.nav.hide.tooltip"/>' > > > onMouseOver="panelButtonHover('navHideImg', collapseImgOver);" > onMouseOut="panelButtonHover('navHideImg', collapseImg);"> > > > <img id="navHideImg" align="middle" alt='<fmt:message > key="main.nav.hide.tooltip"/>' border='0' > > > src='<%= request.getContextPath() + schema.getUrl(application, > "img.panel.arrowleft") %>'/> > > </a> > > </td> > > <td width="3"></td> > > </tr> > > </table> > > </td> > > </tr> > > <tr> > > <td colspan="2" class="panelToolbar"> > > <script language="javascript"> > > toolbarContainer.begin(); > > toolbar.write(); > > toolbarContainer.end(); > > </script> > > </td> > > </tr> > > </table> > > > |