如何从 selenium webdriver 中的验证码获取数据 [英] how to get the data from captcha in selenium webdriver

查看:30
本文介绍了如何从 selenium webdriver 中的验证码获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium webdriver (Java).

I'm using Selenium webdriver (Java).

我需要测试注册表,但在提交之前,会出现图像框(验证码),但每次执行都会更改.我想知道如何从图像(验证码)中获取数据.

I need to test the registration form but before submitting, image box (captcha) is appearing but everytime of execution it is going to be changed. I want to know how to get the data from image (captcha).

谁能帮帮我?

推荐答案

如果验证码来自您控制的环境,您可能需要实现某种方法,表明您在测试环境中并拥有验证码系统返回一个已知值或一些指示预期值的指标.

If the captcha is coming from an environment under your control, you will likely need to implement some sort of method indicating you are in a test environment and have the captcha system return a known value or some indicator of what the expected value is.

另一方面,如果验证码来自您无法控制的其他来源,那么您可能是我们的幸运儿.在这一点上,您基本上与垃圾邮件发送者处于同一条船上,他们一直在进行军备竞赛,以编写可以直观地解析验证码的软件.

If, on the other hand, the captcha is coming from another source out of your control, you are probably our of luck. At that point, you are essentially in the same boat as the spammers who are in a constant arms race to write software that can visually parse a captcha.

更新

我觉得有必要对问题、答案和评论中提出的想法进行一些澄清.本质上,您正在处理以下情况之一(请注意,当我说您的"时,我指的是您、您的公司、客户等):

I feel the need to add some clarification to the ideas put forth in the question, answer and comments. Essentially you are dealing with one of the following situations (note that when I say 'your', I am referring to you, your company, client, etc):

1) 您的表单,您的验证码系统:如果是这种情况,您最好的解决方案是与您的开发人员合作,为您的验证码添加测试"模式,返回已知值或页面中的其他信息这表明预期值应该是什么.如果您能够使用由您或其他人编写的能够成功读取"验证码图像的工具,那么您的系统就坏了.如果您可以在测试模式下执行此操作,那么如何阻止其他任何人(垃圾邮件发送者、黑客等)以完全相同的方式绕过您的验证码.

1) Your form, Your captcha system: If this is the case, your best solution is to work with your developers to add a 'test' mode to your captchas, returning either a known value, or additional information in the page that indicates what the expected value should be. If you are able to make use of a tool, either written by you, or by another, that can successfully 'read' the captcha image, your system is broken. If you can do it in test mode, what is to stop anyone else (spammer, hacker, etc) from bypassing your captcha in exactly the same manner.

2) 您的表单,第 3 方验证码系统:如果是这种情况,您最好的解决方案是再次查看系统是否有一些您可以使用的测试"模式.我自己对这些系统没有经验,但总的来说,我会猜测那里的主要系统存在测试方法.{Captcha System Name} 自动化测试 的 Google 搜索应该会返回一些关于如何使用系统进行测试的好提示.如果没有任何好处,您的下一个赌注是实现您自己的、内部的、仅测试的、虚拟验证码系统,该系统可以使用一些已知值并使您的验证码提供程序可配置,以便您可以在 test/dev 中指向您的测试系统/etc 和你在生产中的真实系统.

2) Your form, 3rd Party captcha system: If this is the case, your best solution is again to see if the system has some 'test' mode that you can make use of. I have no experiance with these systems myself but in general would guess that test methods exist for the major systems out there. A Google search of {Captcha System Name} automated testing should return some good hints as to how to go about testing with the system. If nothing good comes from that, your next bet would be to implement your own, internal, test only, dummy captcha system that works with some known value and make your captcha provider configurable so that you can point to your test system in test/dev/etc and your real system in production.

3) 另一种形式,未知的验证码系统:我将在这里大步向前,并假设这不是你的情况,但为了完整起见,我将包括它.如果这是您的情况,那么您根本没有测试任何东西,只是出于自己的原因寻求帮助绕过其他人的安全机制.如果是这种情况,请在不那么谨慎的网站上寻求您的帮助.

3) Another Form, Unknown captcha system: I am going to make a leap of faith here and assume this is not your case, but just for completeness I will include it. If this is your case, your not testing anything at all and are simply asking for help bypassing someone else's security mechanisms for your own reasons. If that is the case, please seek your assistance on less scrupulous sites.

这篇关于如何从 selenium webdriver 中的验证码获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆