| Line 122... |
Line 122... |
| 122 |
driver.findElement(By.cssSelector(SUBMIT_ICON)).click();
|
122 |
driver.findElement(By.cssSelector(SUBMIT_ICON)).click();
|
| 123 |
|
123 |
|
| 124 |
// Perform click-and-hold action on the element
|
124 |
// Perform click-and-hold action on the element
|
| 125 |
int counter = 1;
|
125 |
int counter = 1;
|
| 126 |
boolean captchaNotBroken = true;
|
126 |
boolean captchaNotBroken = true;
|
| - |
|
127 |
// release() is only reached on the moveByOffset > 0 path, so an attempt
|
| - |
|
128 |
// that fails detection or calibration leaves the button DOWN -- measured
|
| - |
|
129 |
// at 77% of realme presses in production. Actions is one instance per
|
| - |
|
130 |
// driver, created outside the imei loop, so the stuck press leaks into the
|
| - |
|
131 |
// next attempt and the next imei: the following clickAndHold lands on an
|
| - |
|
132 |
// already-held button and the widget never repositions the handle.
|
| - |
|
133 |
boolean pressed = false;
|
| 127 |
do {
|
134 |
do {
|
| 128 |
String fileName = "/tmp/oppo-simple-i-" + counter + " " + System.currentTimeMillis() + ".png";
|
135 |
String fileName = "/tmp/oppo-simple-i-" + counter + " " + System.currentTimeMillis() + ".png";
|
| 129 |
try {
|
136 |
try {
|
| 130 |
LOGGER.info("Starting Do");
|
137 |
LOGGER.info("Starting Do");
|
| 131 |
//Thread.sleep(5000);
|
138 |
//Thread.sleep(5000);
|
| Line 138... |
Line 145... |
| 138 |
//System.out.println("Slide button - " + slideButton);
|
145 |
//System.out.println("Slide button - " + slideButton);
|
| 139 |
LOGGER.info("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
146 |
LOGGER.info("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
| 140 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
147 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
| 141 |
.moveByOffset(1, 0)//.pause(2000)
|
148 |
.moveByOffset(1, 0)//.pause(2000)
|
| 142 |
.perform();
|
149 |
.perform();
|
| - |
|
150 |
pressed = true;
|
| 143 |
|
151 |
|
| 144 |
//actionProvider.moveByOffset(-1,0).pause(2000).perform();
|
152 |
//actionProvider.moveByOffset(-1,0).pause(2000).perform();
|
| 145 |
LOGGER.info("Margin Left after - " + slideButton.getCssValue("margin-left"));
|
153 |
LOGGER.info("Margin Left after - " + slideButton.getCssValue("margin-left"));
|
| 146 |
//Thread.sleep(5000);
|
154 |
//Thread.sleep(5000);
|
| 147 |
} catch (Exception e) {
|
155 |
} catch (Exception e) {
|
| Line 162... |
Line 170... |
| 162 |
if (moveByOffset > 0) {
|
170 |
if (moveByOffset > 0) {
|
| 163 |
// Move, measure again, close the remainder, THEN release.
|
171 |
// Move, measure again, close the remainder, THEN release.
|
| 164 |
actionProvider.moveByOffset(moveByOffset, 0).perform();
|
172 |
actionProvider.moveByOffset(moveByOffset, 0).perform();
|
| 165 |
refine(driver, actionProvider, cal[1]);
|
173 |
refine(driver, actionProvider, cal[1]);
|
| 166 |
actionProvider.release().perform();
|
174 |
actionProvider.release().perform();
|
| - |
|
175 |
pressed = false;
|
| 167 |
LOGGER.info("Move click performed (main {}px)", moveByOffset);
|
176 |
LOGGER.info("Move click performed (main {}px)", moveByOffset);
|
| 168 |
try {
|
177 |
try {
|
| 169 |
// Success used to mean "the dx_captcha_basic_bar-inform error element
|
178 |
// Success used to mean "the dx_captcha_basic_bar-inform error element
|
| 170 |
// did not appear". realme rebuilt this page, so that element may no
|
179 |
// did not appear". realme rebuilt this page, so that element may no
|
| 171 |
// longer exist -- in which case the wait always times out and EVERY
|
180 |
// longer exist -- in which case the wait always times out and EVERY
|
| Line 207... |
Line 216... |
| 207 |
} catch (Throwable e) {
|
216 |
} catch (Throwable e) {
|
| 208 |
LOGGER.warn("Failed = " + counter + " ----------" + e.getMessage());
|
217 |
LOGGER.warn("Failed = " + counter + " ----------" + e.getMessage());
|
| 209 |
}
|
218 |
}
|
| 210 |
}
|
219 |
}
|
| 211 |
}
|
220 |
}
|
| - |
|
221 |
// Any path that got here without releasing (null circles, unusable
|
| - |
|
222 |
// calibration) must let go before the next attempt re-presses.
|
| - |
|
223 |
if (pressed) {
|
| - |
|
224 |
try {
|
| - |
|
225 |
actionProvider.release().perform();
|
| - |
|
226 |
} catch (Exception releaseFailed) {
|
| - |
|
227 |
LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
|
| - |
|
228 |
}
|
| - |
|
229 |
pressed = false;
|
| - |
|
230 |
}
|
| 212 |
LOGGER.info("After circles conditions");
|
231 |
LOGGER.info("After circles conditions");
|
| 213 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
232 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
| 214 |
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_')]")));
|
| 215 |
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_')]"));
|
| 216 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
235 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
| 217 |
LOGGER.info("Ending Do" + counter++);
|
236 |
LOGGER.info("Ending Do" + counter++);
|
| 218 |
|
237 |
|
| 219 |
} while (captchaNotBroken && counter <= 20);
|
238 |
} while (captchaNotBroken && counter <= 20);
|
| - |
|
239 |
// The widget-not-found path breaks out mid-iteration; do not carry a held
|
| - |
|
240 |
// button into the next imei.
|
| - |
|
241 |
if (pressed) {
|
| - |
|
242 |
try {
|
| - |
|
243 |
actionProvider.release().perform();
|
| - |
|
244 |
} catch (Exception releaseFailed) {
|
| - |
|
245 |
LOGGER.warn("Could not release the slider: " + releaseFailed.getMessage());
|
| - |
|
246 |
}
|
| - |
|
247 |
}
|
| 220 |
LOGGER.warn("Counter reached upto 20");
|
248 |
LOGGER.warn("Counter reached upto 20");
|
| 221 |
} catch (Exception e) {
|
249 |
} catch (Exception e) {
|
| 222 |
LOGGER.info("Caught unknown - for imei " + imei);
|
250 |
LOGGER.info("Caught unknown - for imei " + imei);
|
| 223 |
LOGGER.error("Realme warranty check failed for imei " + imei, e);
|
251 |
LOGGER.error("Realme warranty check failed for imei " + imei, e);
|
| 224 |
}
|
252 |
}
|