If it's working sometimes and not others it might be a timing issue.

If the site has lots of javascript, and there's a bunch of client side
rendering that has to happen (along with any other scripting magic)
after the page is loaded, then you might need a small sleep added
before the point of failure, to allow the browser to do it's thing and
be 'ready' to respond to the 'select'  (especially given you've got an
'onchange' event that calls scripts, attached to that element in the
HTML)

On Aug 24, 3:12 am, sudhir <prem...@gmail.com> wrote:
> Hi Chuck,
>
> I tired with ur options and found that is sometimes able to select the
> level0 and its value but sometime not.
> have you faced this weird behavior . Can you please guide.....
> the code I am using is below.........
> require 'watir'
>  test_site = 'http://newpmr2prod.jpmorgan.com/PM/PMlogin.do'
>  b = Watir::Browser.new
>  username='sudhikumar'
>  pwd='jpm'
>  b.goto(test_site)
>  b.text_field(:name, 'userID').set(username)
>  b.text_field(:name, 'password').set(pwd)
>  b.form(:action, '/PM/PMlogin.do').submit
>  b.frame(:name, 'menuMiddle').link(:text, 'Performance').click
>  bu='ABPorts'
>  level='level0'
>  b.frame(:name, 'rightFrame2').select_list(:name,level).select(bu)
>
> Thanks for ur help
>
> On Aug 23, 10:36 pm, Chuck van der Linden <sqa...@gmail.com> wrote:
>
>
>
> > >>b.frame(:name, 'rightFrame2').select_list(:name,level).set(bu)
>
> > 1)  You might want to try using .select  instead of .set    You might
> > also want to first clear any selected items using .clearSelection
>
> > 2)  The value for the method is invalid, none of the <option value>
> > tags for that list have '00907' as a label (nor a value to be
> > returned).  And note that select lists are normally selected by the
> > visible label that the user would see, not the value that selection
> > returns on form submission.   So use bu="ABPorts" or something similar
> > to that.
>
> > 3) it's not finding the element, and based on your code identifying it
> > via :name, "level0" ought to work, so that means there's some other
> > problem, are you sure you have the right frame?  that it's not say
> > "rightFrame1" perhaps?
>
> > 4) I notice there's an onchange event bound to that selection list
> > element, so you might need to fire that event against the selection
> > list after you've changed which item in the list is selected
>
> > b.frame(:name,
> > 'rightFrame1').select_list(:name,level).fire_event('onchange')
>
> > 5)  From a code readability standpoint, it's a lot more direct to just
> > use something like
>
> > b.frame(:name, 'rightFrame1').select_list(:name,
> > 'level0').select('ABPorts')
>
> > rather than using variables which has the effect of forcing someone
> > trying to read the code to go look and see where the variable was
> > assigned, or else memorize those assignments.   Otherwise if you want
> > to use variables like that, assign them at the last possible instant
> > so it's clearer to someone reading your code what the values are.
>
> > On Aug 22, 11:17 pm, sudhir <prem...@gmail.com> wrote:
>
> > >  require 'watir'
> > >  test_site = 'http://newpmr2prod.jpmorgan.com/PM/PMlogin.do'
> > >  b = Watir::Browser.new
> > >  username='sudhikumar'
> > >  pwd='jpm'
> > > level='level0'
> > >  bu='00907'
> > >  b.goto(test_site)
> > >  b.text_field(:name, 'userID').set(username)
> > >  b.text_field(:name, 'password').set(pwd)
> > >  b.form(:action, '/PM/PMlogin.do').submit
> > >  b.frame(:name, 'menuMiddle').link(:text, 'Performance').click
> > >  b.frame(:name, 'rightFrame2').select_list(:name,level).set(bu)
> > > => false
> > > => "http://newpmr2prod.jpmorgan.com/PM/PMlogin.do";
> > > => #<Watir::IE:0xc752478 url="about:blank" title="">
> > > => "sudhikumar"
> > > => "jpm"
> > > => "level0"
> > > => "00907"
> > > => 6.37
> > > => ""
> > > => ""
> > > => 5.137
> > > => 1.468
> > > Watir::Exception::UnknownObjectException: Unable to locate element,
> > > using :name, "level0"
> > >         from 
> > > C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:
> > > 56:in `assert_exists'
> > >         from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/
> > > input_elements.rb:62:in `select_item_in_select_list'
> > >         from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/
> > > input_elements.rb:46:in `set'
> > >         from (irb):136
> > >         from :0
>
> > > <!---->
>
> > > <html>
> > >         <head>
> > >                 <title>JPM PM system</title>
>
> > > <base href="http://newpmr2prod.jpmorgan.com:80/PM/";>
>
> > > <script language='javascript'>
> > >         history.go(1);
> > > </script>
>
> > > <script language="javascript" src="./includes/common/TimerDiv.js"></
> > > script>
> > > <link rel="stylesheet" href="./stylesheet.css" type="text/css">
>
> > >                 <script language="javascript" 
> > > src="./includes/common/lib_func.js"></
> > > script>
> > >                 <script language="javascript" 
> > > src="./includes/common/common.js"></
> > > script>
> > >                 <script language="javascript" src="./includes/common/
> > > lib_submitfrm.js"></script>
> > >                 <script language="javascript" 
> > > src="./includes/reporttemplate/perf/
> > > perftemplateview.js"></script>
> > >                 <script language="javascript">
> > >                         var isTemplateAvbl = false;
> > >                         function submitReportTypes(mode){
> > >                                 var selectIndex =
> > > document.forms[0].selectedReportDetailsString.selectedIndex;
> > > parent.rightFrame2.document.forms[0].reportDetailsString.value=parent.right
> > >  
> > > Frame2.document.forms[0].selectedReportDetailsString.options[selectIndex].v
> > >  alue;
>
> > > parent.rightFrame2.document.forms[0].operation.value="ReportTemplate_Report
> > >  select";
> > >                                 
> > > parent.rightFrame2.document.forms[0].submit();
> > >                         }
>
> > >                 function changetext(whichcontent,i){
> > >                         if (document.all||document.getElementById){
> > >                                 desc = "descriptions"+i;
> > >                                 var cross_el=document.getElementById?
> > > document.getElementById(desc):eval("document.all."+desc);
> > >                                 cross_el.style.visibility = "visible";
> > >                         }
> > >                         else if (document.layers){
> > >                                 desc1 = "a"+i;
> > >                                 obj1 = eval("document."+desc1);
> > >                                 obj1.visibility = "visible";
> > >                         }
> > >                 }
>
> > >                 function hidetext(i){
> > >                         if (document.all||document.getElementById){
> > >                                 desc = "descriptions"+i;
> > >                                 var cross_el=document.getElementById?
> > > document.getElementById(desc):eval("document.all."+desc);
> > >                                 cross_el.style.visibility="hidden";
> > >                         }else{
> > >                                 desc1 = "a"+i;
> > >                                 obj1 = eval("document."+desc1);
> > >                                 obj1.visibility = "hidden";
> > >                         }
> > >                 }
>
> > >                 function MM_reloadPage(init) {  //reloads the window if 
> > > Nav4 resized
> > >                   if (init==true) with (navigator) {if
> > > ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
> > >                         document.MM_pgW=innerWidth;  
> > > onresize=MM_reloadPage; }}
> > >                   else if (innerWidth!=document.MM_pgW ) 
> > > location.reload();
> > >                 }
> > >                 MM_reloadPage(true);
> > >                 // -->
>
> > >                 function MM_findObj(n, d) { //v4.0
> > >                   var p,i,x;  if(!d) d=document;
> > > if((p=n.indexOf("?"))>0&&parent.frames.length) {
> > >                         d=parent.frames[n.substring(p+1)].document; 
> > > n=n.substring(0,p);}
> > >                   if(!(x=d[n])&&d.all) x=d.all[n]; for 
> > > (i=0;!x&&i<d.forms.length;i+
> > > +) x=d.forms[i][n];
> > >                   for(i=0;!x&&d.layers&&i<d.layers.length;i++)
> > > x=MM_findObj(n,d.layers[i].document);
> > >                   if(!x && document.getElementById) 
> > > x=document.getElementById(n);
> > > return x;
> > >                 }
>
> > >                 function MM_showHideLayers() { //v3.0
> > >                   var i,p,v,obj,args=MM_showHideLayers.arguments;
> > >                   for (i=0; i<(args.length-2); i+=3) if 
> > > ((obj=MM_findObj(args[i]))!
> > > =null) { v=args[i+2];
> > >                         if (obj.style) { obj=obj.style; 
> > > v=(v=='show')?'visible':
> > > (v='hide')?'hidden':v; }
> > >                         obj.visibility=v; }
> > >                 }
>
> > >         </script>
> > >         </head>
>
> > >         <body class="FormBackground" leftmargin="0" topmargin="0"
> > > marginwidth="0" marginheight="0">
> > >                 <form name="ReportTemplateListBean" method="POST" 
> > > action="/PM/
> > > perfreporttemplate.do">
> > >                         <input type="hidden" name="selectedLevel" 
> > > value="0">
> > >                         <input type="hidden" name="dimensionVOString" 
> > > value="">
> > >                         <input type="hidden" name="reportDetailsString" 
> > > value="">
> > >                         <input type="hidden" name="reportType" value="">
> > >                         <input type="hidden" name="currentUser" 
> > > value="sudhikumar">
> > >                         <input type="hidden" name="PERF_BY_DIM" 
> > > value="Performance by
> > > Dimension">
> > >                         <input type="hidden" name="buMigStatus" value="">
> > >                         <input type="hidden" name="reportMode" value="">
>
> > >                         <input type="hidden"
>
> ...
>
> read more »

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com

Reply via email to