Subversion Repositories SmartDukaan

Rev

Rev 37435 | Rev 37446 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37435 Rev 37445
Line 233... Line 233...
233
                            wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
233
                            wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
234
                            slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
234
                            slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
235
                            actionProvider.moveToElement(slideButton).doubleClick().perform();
235
                            actionProvider.moveToElement(slideButton).doubleClick().perform();
236
                            LOGGER.info("Ending Do" + counter++);
236
                            LOGGER.info("Ending Do" + counter++);
237
 
237
 
238
                        } while (captchaNotBroken && counter <= 20);
238
                        } while (captchaNotBroken && counter <= MAX_CAPTCHA_ATTEMPTS);
239
                        // The widget-not-found path breaks out mid-iteration; do not carry a held
239
                        // The widget-not-found path breaks out mid-iteration; do not carry a held
240
                        // button into the next imei.
240
                        // button into the next imei.
241
                        if (pressed) {
241
                        if (pressed) {
242
                            try {
242
                            try {
243
                                actionProvider.release().perform();
243
                                actionProvider.release().perform();
244
                            } catch (Exception releaseFailed) {
244
                            } catch (Exception releaseFailed) {
245
                                LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
245
                                LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
246
                            }
246
                            }
247
                        }
247
                        }
248
                        LOGGER.warn("Counter reached upto 20");
248
                        LOGGER.warn("Gave up after {} captcha attempts - imei stays pending for the next tick", MAX_CAPTCHA_ATTEMPTS);
249
                    } catch (Exception e) {
249
                    } catch (Exception e) {
250
                        LOGGER.info("Caught unknown - for imei " + imei);
250
                        LOGGER.info("Caught unknown - for imei " + imei);
251
                        LOGGER.error("Realme warranty check failed for imei " + imei, e);
251
                        LOGGER.error("Realme warranty check failed for imei " + imei, e);
252
                    }
252
                    }
253
                    driver.get("https://www.realme.com/in/support/phonecheck");
253
                    driver.get("https://www.realme.com/in/support/phonecheck");
Line 299... Line 299...
299
     * oppo improves, bring 0.70 over here and measure it on its own.
299
     * oppo improves, bring 0.70 over here and measure it on its own.
300
     */
300
     */
301
    private static final double ASSUMED_RATIO = 1.7;
301
    private static final double ASSUMED_RATIO = 1.7;
302
    private static final int MIN_NUDGE = 10;
302
    private static final int MIN_NUDGE = 10;
303
    private static final int MAX_NUDGE = 60;
303
    private static final int MAX_NUDGE = 60;
-
 
304
    /**
-
 
305
     * Captcha attempts per imei per tick, before giving up and letting the next tick
-
 
306
     * retry with a FRESH page and session. The imei is never abandoned -- it stays
-
 
307
     * pending and returns in ~5 minutes.
-
 
308
     *
-
 
309
     * 12, NOT oppo's 7. Realme has not had the glide change, so its successes still
-
 
310
     * spread late. Measured over 399 successes and 610 exhausted imeis:
-
 
311
     *   cap  7 -> only 83.5% of successes kept (16.5% lost), 59.2% of work saved
-
 
312
     *   cap 12 -> 96.0% kept, 35.7% saved     <- here
-
 
313
     *   cap 14 -> 97.7% kept, 26.7% saved
-
 
314
     * Realme burns more than twice oppo's captcha work, so even this gentler cap saves
-
 
315
     * more in absolute terms (4,937 attempts vs oppo's 3,648).
-
 
316
     *
-
 
317
     * If glide is ever ported here, expect the curve to shift left as oppo's did
-
 
318
     * (33% -> 2% of successes from attempts 8-20) and this can come down to ~7.
-
 
319
     */
-
 
320
    private static final int MAX_CAPTCHA_ATTEMPTS = 12;
-
 
321
 
304
    private static final double ALIGNED_PX = 2.0;
322
    private static final double ALIGNED_PX = 2.0;
305
 
323
 
306
    private static int nudgeFor(double gap) {
324
    private static int nudgeFor(double gap) {
307
        int n = (int) Math.round(gap / (2 * ASSUMED_RATIO));
325
        int n = (int) Math.round(gap / (2 * ASSUMED_RATIO));
308
        return Math.max(MIN_NUDGE, Math.min(MAX_NUDGE, n));
326
        return Math.max(MIN_NUDGE, Math.min(MAX_NUDGE, n));