How to extract Regular expression in Jmeter for the following

613 Views Asked by At

     <html>
        <head>
        <title>HR WorkWays</title>
        <SCRIPT LANGUAGE="JavaScript">
        if(window.history.forward(1) != null) window.history.forward(1);
        </script>
        <script language="JavaScript" src="/theme/disabledRightclick.js""></script>
        <SCRIPT LANGUAGE=JavaScript FOR=window EVENT=onbeforeunload>
        if (window.event.clientY < 0 && window.event.clientY < -80) {
            valuex=window.event.returnValue = "";
        
            }
        </script>
        
        
        
        
        
        </head>
        <body>
        </body>
        </html>     
        
        
         
        
        
        
        
        
        
        
        
        
        
        
        <!-- Added for GSFIX -->
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <div style="font: bold 12px Arial; color:#FF0000"></div>
        
        <html>
        <head>
        <title>PAN NO</title>
        <style type="text/css">
        div#rolltipDiv {
          position:absolute; visibility:hidden;
          left:0; top:0; z-index:1000;
          font:Arial, Helvetica, sans-serif;
          width:220px; padding:3px; font-size:11px;
          background-color:#dee7f7; border:1px solid #336; 
          }
        
        .aceTextField {
        border-width: 1;
        border-style: single;
        font-size: 2.5 mm;
        font:Arial, Helvetica, sans-serif;
        font-weight :normal;
        text-align : right;
        }
        .aceNoTextField {
        border-width: 0;
        border-style: single;
        font-size: 2.5 mm;
        font:Arial, Helvetica, sans-serif;
        font-weight :normal;
        text-align : right;
        }
        
        .buttStyle {
        background-color: #EEEEEE;
        border-width: 1;
        border-color: #DDDDDD;
        font-size: 7pt;
        font:Arial, Helvetica, sans-serif;
        font-weight: bold;
        }
            </style>
        <style type="text/css">
        <!--
        .style10 { font:Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; font-weight: bold; }
        .style15 { font:Arial, Helvetica, sans-serif; font-size: 12px; color: #0000ff; font-weight: bold; }
        .style20 { font:Arial, Helvetica, sans-serif; font-size: 9px; color: 2; }
        a {
         font-family: tahoma;
         font-size: xx-small;
        }
        .style42 {color: #FFFFFF; font:Arial, Helvetica, sans-serif;}
        .style58 { font:Arial, Helvetica, sans-serif; font-size: 9px; color: #FFFFFF; font-weight: bold; }
        .style65 {color: #000000  font:Arial, Helvetica, sans-serif;}
        body {
        }
        a:link {
         text-decoration: none;
         color: #000000;
        }
        a:visited {
         text-decoration: none;
         color: #000000;
        }
        a:hover {
         text-decoration: none;
         color: #000000;
        }
        a:active {
         text-decoration: none;
         color: #000000;
        }
        body,td,th {
         color: #000000;
        }
        .style79 {color: #666666  font:Arial, Helvetica, sans-serif;}
        .style86 {font-size: 14px;
            font-weight: bold; 
             font:Arial, Helvetica, sans-serif;
              }
        .style87 {font-size: 14px; color: #000000; }
        .style88 {font-size: 14; }
        .heading 
        {
         border-width:0;
         border-color:#185081;
         text-align:left;   
         font-size: 8pt;  
         font-weight: bold; 
         font:Arial, Helvetica, sans-serif;
         foreground-color:#ffffff;  
        }
        .msgStl 
        {
         border-width:0;
         border-color:#185081;
         text-align:center;   
         font-size: 8pt;  
         font-weight: bold; 
          font:Arial, Helvetica, sans-serif;
         foreground-color:#ffffff;  
        }
        -->
        </style>
        
        <SCRIPT language="javascript">
        // VJK: Later we can remove
         if(window.parent.contents == null) {
          window.showModalDialog('/New_Window_error.html','window','title:Error ; dialogWidth:400px;dialogHeight:310px; status:no'); 
          if(navigator.appName == 'Netscape'){
           window.stop(); 
          } else {
           document.execCommand('stop');
          }
          
         }
        // VJK: Later we can remove
        function doValidate()
        {
         myFrm = document.forms.panNo;
        
         var str_pan = allTrim(myFrm.pan_no.value);
         if(validate_pan(str_pan) == false)
         {
          return false;
         }
         
            if(myFrm.pan_no.value == 'APPPP1234W')
            {
             alert('Please enter a new PAN value.');
             return false;
            }
         
         document.forms.panNo.flag.value='P';
         **document.getElementById("cuen").value="hc|aa|faaf|offaa||faa{a||f^aaaafafafaff||afa|fafff|a}o^f@}c^";**
         
         document.getElementById("url").value="/pan.jsp";
         document.forms.panNo.action="/pan.jsp";
         
         document.forms.panNo.submit();
        }
        
        function allTrim(string)
        {
            var temp = "";
           
            string = '' + string;
           
            splitstring = string.split(" ");
           
            for(i = 0; i < splitstring.length; i++)
            {
             temp += splitstring[i];
            }
           
            return temp;
        }
        
        function validate_pan(str_pan1)
        {
            var str_pan = allTrim(str_pan1); 
         //var str_pan = str_pan1; 
        
         if (str_pan.length == 0) 
         {
          alert("Pan Number cannot be blank.");
          document.getElementById("pan_no").focus();
          return false;
         }
         
            if(str_pan.length!=0 && str_pan!="APPLIEDFOR" && str_pan!="PANAPPLIED" && str_pan!="PANINVALID" && str_pan!="PANNOTAVBL")
            {
                var reg= new RegExp("[A-Z][A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9][A-Z]"); 
                if(reg.test(str_pan)==false)
                {
                    alert("The first 5 characters of Pan No should be alpha in caps, the next 4 should be numerals and the last charater an alphabet in caps OR it should be APPLIEDFOR in capital letters."); 
           document.getElementById("pan_no").focus();
                    return false; 
                } 
                
                if(str_pan.charAt(3)!='P')
             {
                alert("The fourth character of the PAN Number should be aplhabet  P ");
                return false;
             }
             }
        }
        
        function resizePan(obj)
        {
         if(obj.value == 'PAN NOT AVAILABLE / PAN APPLIED')
         {
          obj.size = '12';
          obj.maxLength = '10';
         }  
         document.getElementById('pan_no').value = "";
        }
        </script>
        
        
         <style type='text/css'> body { scrollbar-face-color:ghostwhite; scrollbar-highlight-color:darkgray; scrollbar-3dlight-color:lightblue; scrollbar-darkshadow-color:gray; scrollbar-shadow-color:darkslateblue; scrollbar-arrow-color:midnightblue; scrollbar-track-color:gainsboro; } </style>
        <link href="/theme/Styles_Modified.css" rel="stylesheet" type="text/css" /> 
        </head> 
        <body > 
        
        <form name="panNo" method="post" action="/pan.jsp">
        <INPUT TYPE="hidden" NAME="cuen" id="cuen" VALUE=""> 
        <INPUT TYPE="hidden" NAME="url" id="url" VALUE=""> 
        <center>
        <div align="center"></div>
        <table width="43%" border="0" align="center">
          <tr>
            <td height="168" colspan="3">
              <table bgcolor="#F2F3F4" width="418" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" rules="none">
                <tr bgcolor="#185081" >
                  <td colspan="2"><div align="center" class="tableHeader13">Update PAN </div></td>
                </tr>
                <tr>
                  <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                  <td width="143" class="tableContent11b"><p>&nbsp;Employee ID</p></td>
                  <td width="269" class="tableContent11"><p align="left">21865275</p></td>
                </tr>
                <tr>
                  <td width="143" height="24" class="tableContent11b"><p>&nbsp;Employee Name</p></td>
                  <td width="269" class="tableContent11"><p align="left">ABC21865275</p></td>
                </tr>
                <!--
                <tr bgcolor="#FFFFFF" class="style58">
                  <td width="143" height="24"><p class="style87">&nbsp;Existing PAN</p></td>
                  <td width="269"><p align="left" class="style88">AGOPR99999</p></td>
                </tr>
                -->
                <tr>
                  <td height="26" class="tableContent11b"><span>&nbsp;PAN</span></td>
                  <td width="269" class="tableContent11"><input name="pan_no" id="pan_no" type="text"  size='12' maxlength='10'  value="APPPP1234W" onFocus="resizePan(this)" class="textBoxEntryNo11L" >
                  </td>
                </tr>        
              </table>
              </td>
            </tr>    
        </table>
        
        <table align="center">
         <tr>
          <td>
          <input type="button" name="Submit" value="Confirm PAN"  onClick="doValidate()" class="buttonStyle12">
          </td>
         </tr>
        </table>
         </center>
        <table align="center" width="434">
         <tr>
          <td width="434" height="10"></td>
         </tr>
         <tr>
          <td height="40">
           
            <div class="messageBlue11b">This screen is enabled from 
              01/05/2014
         to  15/11/2014
        </div>
           </td>
           
        
        </table>
        
        <INPUT TYPE='hidden' NAME='jspName' VALUE='pan'> 
         <input type="Hidden" name="flag" VALUE="">
        </form>
         
        
        </body>
        </html>


  [1]: https://i.stack.imgur.com/SS7BO.jpg

For the following response code during get request,i need to extract the value document.getElementById("cuen").value="@aaoacaaaaafaaaaaaaa}ck@|o@@cfff@@k^c@c{a^{ko{{}|{f{c{c{o}{{"; and this need to post to next HTTP request. I used following parameters

![Regular Expression Extractor in Jmeter][10] please elaborate to extract the regex

3

There are 3 best solutions below

0
On BEST ANSWER

Try this,

document.getElementById\(\"cuen\"\)\.value=\"(.*)\";

you need to escape special characters. I have tried it, working on my machine.

7
On

Use below mentioned Regular expression:

.document\.getElementById\(\"cuen\"\)\.value="(.+?)".

Also keep Match No. as "1"

Hope this will help.

2
On

Try bypass marks . ( ) " before value="(.+?)" by mark /

Like: document\ .getElementById\ (\"cuen\"\ )\ .value="(.+?)" <- try without spacebar's