| Line 98... |
Line 98... |
| 98 |
do {
|
98 |
do {
|
| 99 |
System.out.println("Starting Do");
|
99 |
System.out.println("Starting Do");
|
| 100 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_wrapper_1")));
|
100 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_wrapper_1")));
|
| 101 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_slider_1")));
|
101 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_slider_1")));
|
| 102 |
slideButton = driver.findElement(By.id("dx_captcha_basic_slider_1"));
|
102 |
slideButton = driver.findElement(By.id("dx_captcha_basic_slider_1"));
|
| - |
|
103 |
try {
|
| 103 |
actionProvider.moveToElement(slideButton).clickAndHold().moveByOffset(10, 0).perform();
|
104 |
actionProvider.moveToElement(slideButton).clickAndHold().moveByOffset(10, 0).perform();
|
| - |
|
105 |
} catch (StaleElementReferenceException staleElementReferenceException) {
|
| - |
|
106 |
System.out.println("Found stale element for " + imei + ", lets move ahead with fresh imei");
|
| - |
|
107 |
driver.get("https://support.oppo.com/in/warranty-check/");
|
| - |
|
108 |
}
|
| 104 |
Mat circles = getMatCircles(driver, fileName);
|
109 |
Mat circles = getMatCircles(driver, fileName);
|
| 105 |
if (circles.cols() == 2) {
|
110 |
if (circles.cols() == 2) {
|
| 106 |
double firstCircleX = circles.get(0, 0)[0];
|
111 |
double firstCircleX = circles.get(0, 0)[0];
|
| 107 |
double secondCircleX = circles.get(0, 1)[0];
|
112 |
double secondCircleX = circles.get(0, 1)[0];
|
| 108 |
double distance = Math.abs(firstCircleX - secondCircleX);
|
113 |
double distance = Math.abs(firstCircleX - secondCircleX);
|
| Line 117... |
Line 122... |
| 117 |
try {
|
122 |
try {
|
| 118 |
wait5Sec.until(ExpectedConditions.visibilityOfElementLocated(By.className("dx_captcha_basic_bar-inform")));
|
123 |
wait5Sec.until(ExpectedConditions.visibilityOfElementLocated(By.className("dx_captcha_basic_bar-inform")));
|
| 119 |
System.out.println("Failed = " + counter);
|
124 |
System.out.println("Failed = " + counter);
|
| 120 |
} catch (Exception notFailedException) {
|
125 |
} catch (Exception notFailedException) {
|
| 121 |
System.out.println("Success at attempt " + counter);
|
126 |
System.out.println("Success at attempt " + counter);
|
| 122 |
//wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.className("warranty-service--result_info__wrapper")));
|
127 |
List<WebElement> warrantyDateElements = driver.findElements(By.className("warranty-service--result_info__dateValue"));
|
| 123 |
try {
|
128 |
if (warrantyDateElements.size() > 0) {
|
| 124 |
String warrantyDate = driver.findElement(By.className("warranty-service--result_info__dateValue")).getText();
|
129 |
String warrantyDate = warrantyDateElements.get(0).getText();
|
| 125 |
System.out.println("Date -- " + warrantyDate);
|
130 |
System.out.println("Date -- " + warrantyDate);
|
| 126 |
dateMap.put(imei, LocalDate.parse(warrantyDate, DateTimeFormatter.ofPattern("yyyy/MM/dd")).minusYears(1));
|
131 |
dateMap.put(imei, LocalDate.parse(warrantyDate, DateTimeFormatter.ofPattern("yyyy/MM/dd")).minusYears(1));
|
| 127 |
} catch (Exception e) {
|
132 |
} else {
|
| 128 |
System.out.println("Could not capture date");
|
133 |
System.out.println("Could not capture date");
|
| 129 |
dateMap.put(imei, null);
|
134 |
dateMap.put(imei, null);
|
| 130 |
}
|
135 |
}
|
| 131 |
WebElement checkAgainButton = driver.findElement(By.className("van-button--normal"));
|
136 |
WebElement checkAgainButton = driver.findElement(By.className("van-button--normal"));
|
| 132 |
captchaBroken = true;
|
137 |
captchaBroken = true;
|
| Line 150... |
Line 155... |
| 150 |
e.printStackTrace();
|
155 |
e.printStackTrace();
|
| 151 |
}
|
156 |
}
|
| 152 |
}
|
157 |
}
|
| 153 |
mainCount++;
|
158 |
mainCount++;
|
| 154 |
remainingImeis = imeis.stream().filter(x -> dateMap.containsKey(x)).collect(Collectors.toList());
|
159 |
remainingImeis = imeis.stream().filter(x -> dateMap.containsKey(x)).collect(Collectors.toList());
|
| 155 |
} while (mainCount != 10 && dateMap.size() != imeis.size());
|
160 |
} while (mainCount < 10 && dateMap.size() != imeis.size());
|
| 156 |
driver.close();
|
161 |
driver.close();
|
| 157 |
driver.quit();
|
162 |
driver.quit();
|
| 158 |
return dateMap;
|
163 |
return dateMap;
|
| 159 |
}
|
164 |
}
|
| 160 |
|
165 |
|