| Line 229... |
Line 229... |
| 229 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
229 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
| 230 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
230 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
| 231 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
231 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
| 232 |
LOGGER.info("Ending Do" + counter++);
|
232 |
LOGGER.info("Ending Do" + counter++);
|
| 233 |
|
233 |
|
| 234 |
} while (captchaNotBroken && counter <= 20);
|
234 |
} while (captchaNotBroken && counter <= MAX_CAPTCHA_ATTEMPTS);
|
| 235 |
// The widget-not-found path breaks out mid-iteration; do not carry a held
|
235 |
// The widget-not-found path breaks out mid-iteration; do not carry a held
|
| 236 |
// button into the next imei.
|
236 |
// button into the next imei.
|
| 237 |
if (pressed) {
|
237 |
if (pressed) {
|
| 238 |
try {
|
238 |
try {
|
| 239 |
actionProvider.release().perform();
|
239 |
actionProvider.release().perform();
|
| 240 |
} catch (Exception releaseFailed) {
|
240 |
} catch (Exception releaseFailed) {
|
| 241 |
LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
|
241 |
LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
|
| 242 |
}
|
242 |
}
|
| 243 |
}
|
243 |
}
|
| 244 |
LOGGER.warn("Counter reached upto 20");
|
244 |
LOGGER.warn("Gave up after {} captcha attempts - imei stays pending for the next tick", MAX_CAPTCHA_ATTEMPTS);
|
| 245 |
} catch (Exception e) {
|
245 |
} catch (Exception e) {
|
| 246 |
LOGGER.error("Oppo warranty check failed for imei " + imei, e);
|
246 |
LOGGER.error("Oppo warranty check failed for imei " + imei, e);
|
| 247 |
}
|
247 |
}
|
| 248 |
driver.get("https://support.oppo.com/in/warranty-check/");
|
248 |
driver.get("https://support.oppo.com/in/warranty-check/");
|
| 249 |
// Every navigation destroys the JS context, taking the capture hook
|
249 |
// Every navigation destroys the JS context, taking the capture hook
|
| Line 399... |
Line 399... |
| 399 |
* aim(). Earlier revisions carried an ASSUMED_RATIO constant, it was tuned twice
|
399 |
* aim(). Earlier revisions carried an ASSUMED_RATIO constant, it was tuned twice
|
| 400 |
* (1.7 -> 0.67 -> 1.7) against contaminated measurements, and it never helped. Do not
|
400 |
* (1.7 -> 0.67 -> 1.7) against contaminated measurements, and it never helped. Do not
|
| 401 |
* reintroduce one: the widget's px-per-px genuinely varies by environment (1.4-1.5 in
|
401 |
* reintroduce one: the widget's px-per-px genuinely varies by environment (1.4-1.5 in
|
| 402 |
* production, 1.1-1.2 locally) and by brand, which is exactly why it must be measured.
|
402 |
* production, 1.1-1.2 locally) and by brand, which is exactly why it must be measured.
|
| 403 |
*/
|
403 |
*/
|
| - |
|
404 |
/**
|
| - |
|
405 |
* Captcha attempts per imei per tick, before giving up and letting the next tick
|
| - |
|
406 |
* retry with a FRESH page and session.
|
| - |
|
407 |
*
|
| - |
|
408 |
* A captcha failure is a technical failure, not an answer, so the imei is never
|
| - |
|
409 |
* abandoned -- it stays pending and comes back in ~5 minutes. What this caps is how
|
| - |
|
410 |
* many times we grind on it inside one already-refused session.
|
| - |
|
411 |
*
|
| - |
|
412 |
* 20 was right before the drag was fixed: pre-glide, 33% of oppo's successes came
|
| - |
|
413 |
* from attempts 8-20. Post-glide (r37440) the drag lands first or second try and the
|
| - |
|
414 |
* tail stopped paying. Measured over 308 post-glide successes and 279 exhausted imeis:
|
| - |
|
415 |
* cap 5 -> 95.5% of successes kept, 67.7% of captcha work saved
|
| - |
|
416 |
* cap 7 -> 97.7% kept, 58.4% saved <- here
|
| - |
|
417 |
* cap 10 -> 99.0% kept, 44.8% saved
|
| - |
|
418 |
* Realme keeps its own, higher cap: it has no glide yet, so its successes still
|
| - |
|
419 |
* spread to attempt 10+ and 7 would cost it 16.5%. Re-check the histogram after a
|
| - |
|
420 |
* day; if the distribution shifts, so should this.
|
| - |
|
421 |
*/
|
| - |
|
422 |
private static final int MAX_CAPTCHA_ATTEMPTS = 7;
|
| - |
|
423 |
|
| 404 |
private static final double ALIGNED_PX = 2.0;
|
424 |
private static final double ALIGNED_PX = 2.0;
|
| 405 |
|
425 |
|
| 406 |
/**
|
426 |
/**
|
| 407 |
* margin-left for logging only. Reading it off a detached element throws, and this is
|
427 |
* margin-left for logging only. Reading it off a detached element throws, and this is
|
| 408 |
* a diagnostic -- it must never be the reason an attempt is abandoned.
|
428 |
* a diagnostic -- it must never be the reason an attempt is abandoned.
|