问题
I'm trying to automate a login process on a website using Selenium. I want to enter my data, then enter the captcha myself. However, when I click on the captcha I am given a large amount of captchas and errors. Is there any way for me to not run into constant captchas?
回答1:
Captchas are specifically designed to break automation. I would ask the Product Owner to add some kind of a cookie or mechanism to cause the chaptcha to not be there.
回答2:
Unfortunately, as @Dominic said, CAPTCHA's can't be broken. But I've asked developers to include for test environment URL parameter which can be used in test environment to disable/hide CAPTCH-as. But If You like to investigate I've heard about this service http://deathbycaptcha.com that have to be paid of course.
Here is some complementary code:
import com.DeathByCaptcha.AccessDeniedException;
import com.DeathByCaptcha.Captcha;
import com.DeathByCaptcha.Client;
import com.DeathByCaptcha.SocketClient;
import com.DeathByCaptcha.HttpClient;
/* Put your DeathByCaptcha account username and password here.
Use HttpClient for HTTP API. */
Client client = (Client)new SocketClient(username, password);
try {
double balance = client.getBalance();
/* Put your CAPTCHA file name, or file object, or arbitrary input stream,
or an array of bytes, and optional solving timeout (in seconds) here: */
Captcha captcha = client.decode(captchaFileName, timeout);
if (null != captcha) {
/* The CAPTCHA was solved; captcha.id property holds its numeric ID,
and captcha.text holds its text. */
System.out.println("CAPTCHA " + captcha.id + " solved: " + captcha.text);
if (/* check if the CAPTCHA was incorrectly solved */) {
client.report(captcha);
}
}
} catch (AccessDeniedException e) {
/* Access to DBC API denied, check your credentials and/or balance */
}
This code wasn't tested, I've just found on web, maybe it will help You out.
来源:https://stackoverflow.com/questions/50516616/getting-past-captcha-selenium