Getting Past Captcha - Selenium

让人想犯罪 __ 提交于 2019-12-13 08:59:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!