2 Replies Latest reply: Dec 20, 2012 7:23 AM by 878316 RSS

    Steps to execute Javascript function in a Web UI test in Open script

    878316
      Hi,

      How to execute a javascript or javascript function in a Web UI script. Please help me with step-by-step appraoch
        • 1. Re: Steps to execute Javascript function in a Web UI test in Open script
          834498
          As discussed this afternoon:
          A sample below
          String javaScript = "function getCookie(cookiename)"+
                         "{"+
                         "var i,x,y,ARRcookies=document.cookie.split(';');"+
                         "for (i=0;i<ARRcookies.length;i++)"+
                         " {"+
                         " x=ARRcookies.substr(0,ARRcookies[i].indexOf('='));"+
                         " y=ARRcookies[i].substr(ARRcookies[i].indexOf('=')+1);"+
                         " x=x.replace(/^\\s+|\\s+$/g,\"\");"+
                         " if (x==cookiename)"+
                         " {"+
                         " return unescape(y);"+
                         " }"+
                         " }"+
                         "}";

                         
                         web.document( "/web:window[@index='*']/web:document[@index='*']").executeJavaScript(javaScript);