Took two days to complete the verification code to complete the login operation, on the internet to see a lot of verification code identification method, but I use the QTP version is more advanced, so still want to spend their own mind research. Detailed history of my identification verification code on PO:
First, read the image verification code in the browser
1. Open the browser login screen 2. Start QTP, uncheck the Web
3. Record the verification code. Start recording: Select Insert->text area output value on the recorded strip. The box for the captcha picture.
Then select modify,output types set to Environment,name can be rewritten as "GetChar". Stop Recording
The resulting code is:
Window ("Windows Internet Explorer"). Winobject ("Internet explorer_server"). Output CheckPoint ("Internet explorer_server") 4. Add a line to the code after recording:
MsgBox Environment. Value ("GetChar")5. Click Run on QTP
So it pops up the CAPTCHA message box.
Second, identify the numbers in Word. Replay the recorded verification code in QTP and output the verification code:
In Word, select a picture, the content is a number, get the number in the picture. Then get to the number in Word to output: 1, open QTP, do not select Web. Use text area output value to select a picture in Word, a number, to get the number in the picture, and save it as an environment variable GETCHAR3 when recording.
2. Create a new test to invoke the action you just recorded. Then record in Word to enter a paragraph of text. 3. Change the text to the value of the environment variable GETCHAR3 so that the value of the verification code is printed in Word. The code for the second Test is as follows:
Runaction "Copy of Action1", oneiteration
MsgBox environment. Value ("Getchar3") #将环境变量的值用messagebox弹出来
Myword=environment. Value ("Getchar3") #将环境变量的值复制给一个变量Window ("Microsoft Word"). Winobject ("Microsoft Word Document"). Type MyWord #这句是录制得到的. It would have been type "1234", and "1234" would have been changed to type.
Three, the complete login OA system. The following is the code content for action name Oa_login_code. Record the Checkcode action without the Web identification code first, and then tick web AddIn to record the action logged in to the OA system. The login interface of OA when recording is open.
In Checkcode action, you can see GetChar in file--setting--environment--internal value. However, you cannot see this environment variable value in the action that invokes it. You can use this environment variable directly. Runaction "Copy of Checkcode", oneiteration
Mywebelement=environment. Value ("GetChar")
Browser ("Process pipeline, knowledge living Water"). Page ("Process pipeline, knowledge living Water"). Webedit ("Authcode"). Set mywebelement
Browser ("Process pipeline, knowledge living Water"). Page ("Process pipeline, knowledge living Water"). Webedit ("J_username"). Set "078057"
Browser ("process pipeline, knowledge living Water"). Page ("Process pipeline, knowledge living Water"). Webedit ("J password")
Browser ("Process pipeline, knowledge living Water"). Page ("Process pipeline, knowledge living Water"). Webedit ("J_password"). SetSecure "541303024777c70d"
Browser ("Process pipeline, knowledge living Water"). Page ("Process pipeline, knowledge living Water"). Image ("Submit"). Click 2,12
Where the Checkcode action code:
Window ("Windows Internet Explorer"). Winobject ("Internet explorer_server"). Output CheckPoint ("Internet explorer_server")
Results after running the full action:
Error Record one: The above code is recorded in the form of Windows Verification code picture read the text value, and save it as an environment variable GetChar. I save the value as global data, the value will not change when playing back, and the Save As environment variable will get the correct verification code every time. Error Record two: When I run the calling program alone, I can see that the verification code was successful in QTP's own result. However, the first user name, re-password, and then verify the code, the value of the obtained verification code is empty. Then the statement that calls the identification code is placed in the first sentence, first enter the verification code (the code above is the code that runs successfully). This will allow you to log in successfully.this may be because the recognition box is crawled by mouse and coordinate.
By identifying the verification code of the program to learn:
1. Block multiple lines, verify a line independently to see if it passes. Then the multi-step 2.QTP verification code recognition is performed by capturing the text in the image. Only English is now recognized. If you select Chinese when recording (set in Tools-options--gui testing-text recognition), it is also not recognized. qtp11.5 OCR settings: Set in Tools-options--gui testing-text recognition. The only way I'm Win7 is with OCR. 3. When recording, sometimes recording does not generate code, sometimes playback is unsuccessful, to reopen IE browser.
QTP Identification Verification Code