Loadrunner uses the system () function to call Tesseract-OCR to identify Verification Code Problems

Source: Internet
Author: User

As the saying goes, people planted trees, and future generations are taking advantage of the cold. This is not false at all. Combined with the article on the cloud layer: verification code ).

Download tesseract-ocr-setup-3.02.02.exe from code.google, which is a windows version. After downloading and installing tesseract-ocr-setup-3.02.02.exe, the installation path is automatically added to the environment variable. You can manually test it in cmd:

Format: tesseract.exe c: \ test1.jpg c: \ test-l

// Test1.jpg.

The script provided by the cloud layer cannot be run in system ("c: \ test. bat"), and the batch processing script will not be available in a flash. Changed system ("c: \ test. bat");, modified the batch processing file, added pause, and prompted an error. For example:

The loadrunnertool does not recognize the tesseract.exe command, but it is possible to manually run it in any directory. Do you not recognize the path environment variables in windows through the terminal window opened by LR ?? This will be serious later ..

It seems that you can only modify this batch file, and specify the path to the installation directory of tesseract.

After the operation succeeds, you can see the obtained verification code in the automatically generated test.txt, or you can see the verification code in the LR output: t4zbyh

I tried several verification codes. Most of them are correct,

Which of the following cannot be identified (March 8, 2013 supplement: not all HTTPS can not be identified, the credit card center of Citic Bank Verification Code (pure numbers) can be identified https://creditcard.ecitic.com/citiccard/cppnew/jsp/valicode.jsp? Time = 1362724476515. Some reasons why the verification code is not recognized are still to be explored. Why is the https pure-digit verification code available, do other verification codes contain English characters, bold characters, or images that are too large ??) : With HTTPS,

Https://passport.csdn.net/ajax/verifyhandler.ashx? R_d = 63178

The following is the loadrunner Script: Create a test. bat batch in drive C.

Action () {int flen; // define an integer variable to save and obtain the file size long filedes; // save the file handle char file [256] = "c: \ test1.jpg "; // save the file path and file name char result [10]; // web_set_max_html_param_len ("2000000") for storing the verification code; // set the maximum number of bytes received on the page, this 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 the 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 test. bat file, change the file content as follows:/* c: cd C: \ Program Files \ Tesseract-OCR tesseract.exe c: \ test1.jpg c: \ test-l * // The condition is not an 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); // The length of the Verification Code fclose (filedes); lr_output_message (" result: % s ", result );

Lr_save_string (result, "txtCheck"); // pass the verification code to the txtCheck Parameter

Lr_output_message ("txtCheck: % s", lr_eval_string ("{txtCheck}"); // lr_eval_string ("{txtCheck}") is used in the following logon

return 0;}

In the future, we will be concerned with the accuracy of Tesseract-OCR image recognition to eliminate the impact of https protocol. Currently, the verification code recognition accuracy is about 70%. If it is used in a performance test project or an automated test project, it will greatly reduce the work efficiency, and system () calls batch processing and processing batch processing will also take time. During the formal test, try not to use this tool. The best way is to enable R & D to enable 10 thousand verification code or remove the verification code function.

Okay. Study again tomorrow.

In modern society, e-commerce networks are becoming more and more dependent. It is difficult to say that some abnormal testing needs exist. It is possible to perform automated tests online, and the company has a strong security mechanism constraint, using Tesseract-OCR to identify logon verification codes, registration verification codes, and Payment Verification codes is still very useful. It is imperative to improve the accuracy of Tesseract-OCR recognition.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.