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

查看:102
本文介绍了如何从硒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)您的表单,第三方验证码系统:如果是这种情况,则最好的解决方案是再次查看系统是否具有可以使用的测试"模式.我自己对这些系统没有经验,但是总的来说,我会猜测那里存在主要系统的测试方法. Google搜索 {Captcha系统名称}自动化测试应该会返回一些有关如何进行系统测试的良好提示.如果没有任何好处,那么您的下一个赌注就是实现自己的,内部的,仅测试的,虚拟的验证码系统,该系统以某个已知值工作,并使验证码提供程序可配置,以便您可以在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.

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

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