| Line 111... |
Line 111... |
| 111 |
driver.findElement(By.cssSelector("div.searchBtn")).click();
|
111 |
driver.findElement(By.cssSelector("div.searchBtn")).click();
|
| 112 |
|
112 |
|
| 113 |
// Perform click-and-hold action on the element
|
113 |
// Perform click-and-hold action on the element
|
| 114 |
int counter = 1;
|
114 |
int counter = 1;
|
| 115 |
boolean captchaNotBroken = true;
|
115 |
boolean captchaNotBroken = true;
|
| - |
|
116 |
// release() is only reached on the moveByOffset > 0 path, so an attempt
|
| - |
|
117 |
// that fails detection or calibration leaves the button DOWN. Measured in
|
| - |
|
118 |
// production: 79% of presses were never released. Actions is one instance
|
| - |
|
119 |
// per driver, created outside the imei loop, so the stuck press leaks into
|
| - |
|
120 |
// the next attempt AND the next imei -- the following clickAndHold lands on
|
| - |
|
121 |
// an already-held button, so the widget never repositions the handle and the
|
| - |
|
122 |
// drag continues from wherever the pointer was abandoned.
|
| - |
|
123 |
boolean pressed = false;
|
| 116 |
do {
|
124 |
do {
|
| 117 |
String fileName = "/tmp/oppo-simple-i-" + counter + " " + System.currentTimeMillis() + ".png";
|
125 |
String fileName = "/tmp/oppo-simple-i-" + counter + " " + System.currentTimeMillis() + ".png";
|
| 118 |
try {
|
126 |
try {
|
| 119 |
LOGGER.info("Starting Do");
|
127 |
LOGGER.info("Starting Do");
|
| 120 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
128 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
| Line 123... |
Line 131... |
| 123 |
//System.out.println("Slide button - " + slideButton);
|
131 |
//System.out.println("Slide button - " + slideButton);
|
| 124 |
LOGGER.info("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
132 |
LOGGER.info("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
| 125 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
133 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
| 126 |
.moveByOffset(1, 0)//.pause(2000)
|
134 |
.moveByOffset(1, 0)//.pause(2000)
|
| 127 |
.perform();
|
135 |
.perform();
|
| - |
|
136 |
pressed = true;
|
| 128 |
|
137 |
|
| 129 |
//actionProvider.moveByOffset(-1,0).pause(2000).perform();
|
138 |
//actionProvider.moveByOffset(-1,0).pause(2000).perform();
|
| 130 |
LOGGER.info("Margin Left after - " + slideButton.getCssValue("margin-left"));
|
139 |
LOGGER.info("Margin Left after - " + slideButton.getCssValue("margin-left"));
|
| 131 |
//Thread.sleep(5000);
|
140 |
//Thread.sleep(5000);
|
| 132 |
} catch (Exception e) {
|
141 |
} catch (Exception e) {
|
| Line 150... |
Line 159... |
| 150 |
// releasing. Releasing on the first computed offset committed
|
159 |
// releasing. Releasing on the first computed offset committed
|
| 151 |
// the whole calibration error to the final position.
|
160 |
// the whole calibration error to the final position.
|
| 152 |
actionProvider.moveByOffset(moveByOffset, 0).perform();
|
161 |
actionProvider.moveByOffset(moveByOffset, 0).perform();
|
| 153 |
refine(driver, actionProvider, cal[1]);
|
162 |
refine(driver, actionProvider, cal[1]);
|
| 154 |
actionProvider.release().perform();
|
163 |
actionProvider.release().perform();
|
| - |
|
164 |
pressed = false;
|
| 155 |
LOGGER.info("Move click performed (main {}px)", moveByOffset);
|
165 |
LOGGER.info("Move click performed (main {}px)", moveByOffset);
|
| 156 |
try {
|
166 |
try {
|
| 157 |
try {
|
167 |
try {
|
| 158 |
wait5Sec.until(ExpectedConditions.visibilityOfElementLocated(By.className("dx_captcha_basic_bar-inform")));
|
168 |
wait5Sec.until(ExpectedConditions.visibilityOfElementLocated(By.className("dx_captcha_basic_bar-inform")));
|
| 159 |
// realme logs the widget's own verdict here and oppo did not,
|
169 |
// realme logs the widget's own verdict here and oppo did not,
|
| Line 195... |
Line 205... |
| 195 |
} catch (Throwable e) {
|
205 |
} catch (Throwable e) {
|
| 196 |
LOGGER.warn("Failed = " + counter + " ----------" + e.getMessage());
|
206 |
LOGGER.warn("Failed = " + counter + " ----------" + e.getMessage());
|
| 197 |
}
|
207 |
}
|
| 198 |
}
|
208 |
}
|
| 199 |
}
|
209 |
}
|
| - |
|
210 |
// Any path that got here without releasing (null circles, unusable
|
| - |
|
211 |
// calibration) must let go before the next attempt re-presses.
|
| - |
|
212 |
if (pressed) {
|
| - |
|
213 |
try {
|
| - |
|
214 |
actionProvider.release().perform();
|
| - |
|
215 |
} catch (Exception releaseFailed) {
|
| - |
|
216 |
LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
|
| - |
|
217 |
}
|
| - |
|
218 |
pressed = false;
|
| - |
|
219 |
}
|
| 200 |
LOGGER.info("After circles conditions");
|
220 |
LOGGER.info("After circles conditions");
|
| 201 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
221 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
| 202 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
222 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
| 203 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
223 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
| 204 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
224 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
| 205 |
LOGGER.info("Ending Do" + counter++);
|
225 |
LOGGER.info("Ending Do" + counter++);
|
| 206 |
|
226 |
|
| 207 |
} while (captchaNotBroken && counter <= 20);
|
227 |
} while (captchaNotBroken && counter <= 20);
|
| - |
|
228 |
// The widget-not-found path breaks out mid-iteration; do not carry a held
|
| - |
|
229 |
// button into the next imei.
|
| - |
|
230 |
if (pressed) {
|
| - |
|
231 |
try {
|
| - |
|
232 |
actionProvider.release().perform();
|
| - |
|
233 |
} catch (Exception releaseFailed) {
|
| - |
|
234 |
LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
|
| - |
|
235 |
}
|
| - |
|
236 |
}
|
| 208 |
LOGGER.warn("Counter reached upto 20");
|
237 |
LOGGER.warn("Counter reached upto 20");
|
| 209 |
} catch (Exception e) {
|
238 |
} catch (Exception e) {
|
| 210 |
LOGGER.error("Oppo warranty check failed for imei " + imei, e);
|
239 |
LOGGER.error("Oppo warranty check failed for imei " + imei, e);
|
| 211 |
}
|
240 |
}
|
| 212 |
driver.get("https://support.oppo.com/in/warranty-check/");
|
241 |
driver.get("https://support.oppo.com/in/warranty-check/");
|