Hi,

if it works correctly in "normal" browser then it isn't a bug in your
application but may be some incorrectness that htmlunit doesn't support
(like the html code correctness: </select></table>).

I couldn't fully follow your issue (today is Monday ;-)) but can give a
few hints to narrow it down:
- fix the html code
- is the wrong behavior due to javascript? What happens if you
deactivate it?
- simplify the html code to have only the 2 forms and test again
- reduce the js code (for instance removing the onload, ...) to find
which may cause the problem

Marc.

Koorosh Vakhshoori wrote:
> Hi guys,
> 
>   I have been using WebTest successfully for the pass few years and find
> the tool very useful. Here I am having a problem that I can not figure
> out if it is a WebTest or cased by my application.
> 
>   In my application which is using JSF, I have a page where it has two
> forms which are identical, but different ids of course, one is at the
> top and the other at the bottom of the page. Here is a very simplified
> version of the page in HTML:
> 
>  
> 
> <form id="f1" method="post" action="/dummy"
> enctype="application/x-www-form-urlencoded"> 
> <table>
>       <tr>
>             <td>
>                   <div>
>                         <p><select id="f1:topBlueBar:selectedTeam"
> name="f1:topBlueBar:selectedTeam" size="1" onchange="sync(this);">
>                     <option value="" selected="selected">Select Team to
> Assign</option>
>       <option value="177">test</option>
> </select>
> </table>
> 
> <!-Main body of the page goes here! -->
> 
> <table>
>       <tr>
>             <td>
>                   <div>
>                         <p><select id="f1:bottomBlueBar:selectedTeam"
> name="f1:bottomBlueBar:selectedTeam" size="1" onchange="sync(this);">
>                    <option value="" selected="selected">Select Team to
> Assign</option>
>       <option value="177">test</option>
> </select>
> </table>
>  
> <script>
> window.onscroll = saveScroll;
> </script>
> 
> </form>
> 
> Notice, I am using OnChange to sync one of the select field to the
> other.
> 
> The problem is that when we run the following WebTest script:
> 
>                         <setselectfield
>                               description="Pick an existing team for AC
> assignment"
>                               name="f1:topBlueBar:selectedTeam"
>                               text="test" />
> 
>                         <verifyselectfield
>                               description="Pick an existing team for AC
> assignment"
>                               name="f1:topBlueBar:selectedTeam"
>                               text="test" />
> 
>                         <verifyselectfield
>                               description="Pick an existing team for AC
> assignment"
>                               name="f1:bottomBlueBar:selectedTeam"
>                               text="test" />
> 
>  
> 
> The test fails when it comes to verify my selection. WebTest log tells
> me that I have not selected the item. However, if I select from the
> bottom selection, i.e. f1:bottomBlueBar:selectedTeam, it works fine. I
> have striped down the script to just test the Java Script code, and
> WebTest passes fine. Also I noticed on Web Server side, for the case
> were I having problem I see the field in question is set twice by JSF,
> where the first time it is set to the value I requested and the second
> time it is blank. I believe that is why after the Submit, the generate
> page does not have the selection.
> 
>  
> 
> I was wondering if this is a bug in my application or a WebTest issue. I
> have tested the application manually in IE and FireFox and in both
> browsers, it works as expected. Any suggestions appreciated. I am
> including a strip down version with Java Script code below.
> 
>  
> 
> Thanks,
> 
> Koorosh
>  
> =======================================================================
> <html>
>       <head>
>             <title>Simple test of duplicate banner</title>
>             <script language="JavaScript">
> 
> function findElement(frm, name) {
>       var a = findAllElements(frm, name);
>       if(a.length == 0)
>             return '';
>       return a[0];
> }
> 
> function initScroll() {
>       var f = findElement(document.forms[0], "scrollPos");
>       if(!f)
>             return;
>       window.scrollTo(0, f.value);
> }
> 
> function findAllElements(frm, name) {
>     var a = new Array();
>     var p = 0;
> 
>       for(i = 0; i < frm.length; i++) {
>             var s = frm[i].name;
>             if(!s)
>                   continue;
>             var n = s.lastIndexOf(":");
>             if(n != -1)
>                   s = s.substring(n + 1);
>             if(s == name) {
>                   a[p++] = frm[i];
>             }
>       }
>       return a;
> }
> 
>  
> 
> // find another element whose name ends with name but is not thisElem
> 
> function getOtherElement(name, thisElem) {
>       var a = findAllElements(document.forms[0], name);
>       var i;
>       for(i = 0; i < a.length; i++) 
>             if(a[i].name != thisElem.name)
>                   return a[i];
>       return null;
> }
> 
> function sync(thisElem) {
>       var n = thisElem.name.lastIndexOf(":");
>       var name = n == -1 ? thisElem.name : thisElem.name.substring(n +
> 1);
>       var otherElem = getOtherElement(name, thisElem);
>       if(otherElem == null)
>             return;
>       if(thisElem.type.indexOf("select-") == 0)
>             syncSelect(thisElem, otherElem);
>       else if(thisElem.type == "checkbox")
>             syncCheckbox(thisElem, otherElem);
>       else  // presumably text field
>             otherElem.value = thisElem.value;
> }
> 
> function syncSelect(thisElem, otherElem) {
>       var i;
>       for(i = 0; i < thisElem.options.length; i++)
>             otherElem.options[i].selected =
> thisElem.options[i].selected;
> }
> 
> function syncCheckbox(thisElem, otherElem) {
>       otherElem.checked = thisElem.checked;
> }
>             </script>
>       </head>
> 
> <body bgcolor="#ffffff" 
> 
> onload="
> 
> if(typeof onloadHandler != 'undefined') 
> 
>       onloadHandler();
> 
> initScroll();
> 
> ">
> 
> <form id="f1" method="post" action="/dummy"
> enctype="application/x-www-form-urlencoded">
> 
> <table>
>       <tr>
>             <td>
>                   <div>
>                         <p><select id="f1:topBlueBar:selectedTeam"
> name="f1:topBlueBar:selectedTeam" size="1" onchange="sync(this);">
>                     <option value="" selected="selected">Select Team to
> Assign</option>
>       <option value="177">test</option>
> </select>
> </table>
>  
> <table>
>       <tr>
>             <td>
>                   <div>
>                         <p><select id="f1:bottomBlueBar:selectedTeam"
> name="f1:bottomBlueBar:selectedTeam" size="1" onchange="sync(this);">
>                    <option value="" selected="selected">Select Team to
> Assign</option>
>       <option value="177">test</option>
> </select>
> </table>
> 
> <script>
> 
> window.onscroll = saveScroll;
> 
> </script>
> 
> </form>
> 
> </body>
> 
> </html>
> 
> 
> _______________________________________________
> WebTest mailing list
> [email protected]
> http://lists.canoo.com/mailman/listinfo/webtest
> 

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to