问题
I am trying to automate one form where I get re-Captcha as a part of form submission. I got stuck and figuring out that how can we handle the captcha text using selenium webdriver. Though this captcha is turing test implementation in realtime but, still I am finding some way so that I can handle this scenario.
回答1:
So you can't really do that, captcha is by definition meant to break your automation. That said, I have had some luck using Tesseract OCR, but I was dealing with rather simplistic ones that contained only numbers. While I was doing that, I also looked into some javascript based solutions, but I was unable to achieve any success with those. I think it is worth giving a try, but most probably you are out of luck
回答2:
If you are using the new Google unobtrusive reCaptcha v3, the back end call to https://www.google.com/recaptcha/api/siteverify
returns a score value between 0 (100% Bot) and 1.0 (100% human). You can choose the threshold level of 'humanity' and, can move this threshold into environment-specific configurations.
e.g. What we do is set a threshold value of around 0.7 in our production system, but in our development environments where we run our Selenium tests, we set this threshold to 0 in order to allow our Se tests to verify the functional correctness of our external facing forms.
We have also run a Selenium smoke test against our production environment (where the threshold is 0.7) to ensure that the Captcha is correctly configured and does prevent abuse.
来源:https://stackoverflow.com/questions/29466687/captcha-handling-using-selenium