2013/03/25

LoadRunner using the system () function call Tesseract-OCR recognition verification code script code

Here is loadrunner script: C disk Establish test.bat batch:
Action ()
{
    int flen; / / define an integer variable to hold the size of the file
    long filedes; / / save the file handle
    char file [256] = "c: \ \ test1.jpg"; / / save the file path and file name
    char result [10]; / / store verification code

    web_set_max_html_param_len ("2000000") ;
/ / set the page to receive the maximum number of bytes, the setting should be greater than the download file size

         web_reg_save_param ("pic",
                   "LB =",
                   "RB =",
                   "Ord = 1",
                   "Search = Body",
                   LAST);

         web_url ("randpiccloud", "URL = https://passport.csdn.net/ajax/verifyhandler.ashx?r_d=63178", LAST);

         / / Http://biz.ftuan.com/CheckImg.aspx
         / / Http://passport.ftuan.com/SecurityCode.aspx?refresh=Wed Mar 6 11:21:21 UTC +0800 2013
         / / Http://comment8.mydrivers.com/radompage.aspx?0. {Rnum}
         / / Https://passport.gaopeng.com/captcha?w=98&h=36&r=0.4655476964544505
         / / Https://passport.csdn.net/ajax/verifyhandler.ashx?r_d=63178

    
    flen = web_get_int_property (HTTP_INFO_DOWNLOAD_SIZE); / / get file size

    if (flen> 0)
    {
        if ((filedes = fopen (file, "wb")) == NULL)
        {
            lr_output_message ("oh cloud your Open File Failed!");
            return -1;
        }
        fwrite (lr_eval_string ("{pic}"), flen, 1, filedes);

        fclose (filedes);
    }


       system ("c: \ \ test.bat");
       / / Call the C drive under test.bat file, change the file as follows:
       / *
        c:
        cd C: \ Program Files \ Tesseract-OCR
        tesseract.exe c: \ test1.jpg c: \ test-l
       * /
       / / First, download the the Tesseract tools and installation, must cd to the installation directory in a batch file, or LR called the prompt "tesseract.exe than internal command"

       if ((filedes = fopen ("c: \ \ test.txt", "rt")) == NULL)
        {
            lr_output_message ("oh, cloud your Open File Failed!");
            return -1;
        }
        fread (result, 5,1, filedes); / / here to control the length of the verification code
        fclose (filedes);

         lr_output_message ("result:% s", result);
lr_save_string (result, "txtCheck"); / / pass validation code to txtCheck parameters
lr_output_message ("txtCheck:% s", lr_eval_string ("{txtCheck}")); / / lr_eval_string ("{txtCheck}") used in the following registry
return 0;
}


没有评论:

发表评论