有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Recaptcha和selenium

我正在尝试通过Recaptcha验证。我面临的问题是,有时它会在没有图像的情况下进行检查,大多数情况下,它会给出图像。 有没有办法或者有人知道Recaptcha在没有图像的情况下进行检查的要求? 我不能禁用Recaptcha。 如果我停止使用selenium来手动解决问题,那么使用selenium是没有意义的。 我的代码:

SoftAssert Sa = new SoftAssert();
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofMillis(20000));
        JavascriptExecutor js = (JavascriptExecutor) driver;
        String FormatMessageInformatife = "<font color='#73a9d0'></br><i class='fas fa-info-circle'></i>- ";
        String FormatMessageError = "<font color='#bf3d27'></br><i class='fas fa-times-circle'></i>- ";
        String FormatMessageSucces = "<font color='#69c158'></br><i class='fas fa-check-circle'></i>-";
        WebElement ClkSignup = driver.findElement(By.id("toggle-button"));
        ClkSignup.click();
        WebElement ClkSubscribe = driver
                .findElement(By.xpath("//div[@id=\"dialog-07zr\"]/div[@class=\"boutons-yellow\"]/a[1]/button"));
        ClkSubscribe.click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='steps-title']/ul/li[@class='active'][1]/span[normalize-space(text())='Coordonnées']")));
        Boolean AccesSubscription = driver.findElements(By.xpath("//div[@class='steps-title']/ul/li[@class='active'][1]/span[normalize-space(text())='Coordonnées']")).size() > 0;
        if(AccesSubscription == true) {
            Reporter.log(FormatMessageSucces + " Accessed Subscription </font>");
            WebElement TVAInput = driver.findElement(By.id("create_account_step1_tva"));
            sendHumanKeys(TVAInput,"FR75850236541");
            WebElement EmailInput = driver.findElement(By.id("create_account_step1_mail"));
            sendHumanKeys(EmailInput,"test2021test@gmail.com");
            WebElement PhoneInput = driver.findElement(By.id("create_account_step1_phone"));
            sendHumanKeys(PhoneInput,"0721547861");
            WebElement PwdInput = driver.findElement(By.id("create_account_step1_password_first"));
            sendHumanKeys(PwdInput,"Test07ZR");
            WebElement CPwdInput = driver.findElement(By.id("create_account_step1_password_second"));
            sendHumanKeys(CPwdInput,"Test07ZR");
            wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@name, 'a-') and starts-with(@src, 'https://www.google.com/recaptcha')]")));
            Thread.sleep(10000);
            WebElement CaptchaClk = driver.findElement(By.cssSelector("div.recaptcha-checkbox-checkmark"));
            js.executeScript("arguments[0].click();", CaptchaClk);
            WebElement RBClk = driver.findElement(By.xpath("//div[@id=\"checkbox\"]/label"));
            js.executeScript("arguments[0].click();", RBClk);
            WebElement ClkNext = driver.findElement(By.id("bt"));
            js.executeScript("arguments[0].click();", ClkNext);
            }else {
            Sa.assertEquals(false, true, "Wasn't abel to acces Subscription");
            ScreenShot(driver);
            Reporter.log(FormatMessageError + " Wasn't abel to acces Subscription</font>");

共 (0) 个答案