| Line 84... |
Line 84... |
| 84 |
WebDriverWait wait5Sec = new WebDriverWait(driver, 4);
|
84 |
WebDriverWait wait5Sec = new WebDriverWait(driver, 4);
|
| 85 |
WebElement slideButton;
|
85 |
WebElement slideButton;
|
| 86 |
Actions actionProvider = new Actions(driver);
|
86 |
Actions actionProvider = new Actions(driver);
|
| 87 |
do {
|
87 |
do {
|
| 88 |
driver.get("https://www.realme.com/in/support/phonecheck");
|
88 |
driver.get("https://www.realme.com/in/support/phonecheck");
|
| 89 |
try {
|
89 |
/*try {
|
| 90 |
driver.findElement(By.cssSelector(".cp-cookie-tip a.close")).click();
|
90 |
driver.findElement(By.cssSelector(".cp-cookie-tip a.close")).click();
|
| 91 |
} catch (Exception e) {
|
91 |
} catch (Exception e) {
|
| 92 |
try {
|
92 |
try {
|
| 93 |
System.out.println("Cookie not found");
|
93 |
System.out.println("Cookie not found");
|
| 94 |
} catch (Exception e1) {
|
94 |
} catch (Exception e1) {
|
| 95 |
}
|
95 |
}
|
| 96 |
}
|
96 |
}*/
|
| 97 |
|
97 |
|
| 98 |
for (int i = 0; i < remainingImeis.size(); i++) {
|
98 |
for (int i = 0; i < remainingImeis.size(); i++) {
|
| 99 |
String imei = remainingImeis.get(i);
|
99 |
String imei = remainingImeis.get(i);
|
| 100 |
try {
|
100 |
try {
|
| 101 |
System.out.println("Starting fresh with new IMEI " + imei);
|
101 |
System.out.println("Starting fresh with new IMEI " + imei);
|
| Line 117... |
Line 117... |
| 117 |
try {
|
117 |
try {
|
| 118 |
System.out.println("Starting Do");
|
118 |
System.out.println("Starting Do");
|
| 119 |
//Thread.sleep(5000);
|
119 |
//Thread.sleep(5000);
|
| 120 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.tagName("canvas")));
|
120 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.tagName("canvas")));
|
| 121 |
|
121 |
|
| 122 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='dx_captcha_basic_bg_1' or @id='dx_captcha_basic_bg_2' or @id='dx_captcha_basic_bg_3' or @id='dx_captcha_basic_bg_4' or @id='dx_captcha_basic_bg_5' or @id='dx_captcha_basic_bg_6' or @id='dx_captcha_basic_bg_7' or @id='dx_captcha_basic_bg_8']")));
|
122 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_bg_')]")));
|
| 123 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='dx_captcha_basic_wrapper_1' or @id='dx_captcha_basic_wrapper_2' or @id='dx_captcha_basic_wrapper_3' or @id='dx_captcha_basic_wrapper_4' or @id='dx_captcha_basic_wrapper_5' or @id='dx_captcha_basic_wrapper_6' or @id='dx_captcha_basic_wrapper_7' or @id='dx_captcha_basic_wrapper_8']")));
|
123 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
| 124 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='dx_captcha_basic_slider_1' or @id='dx_captcha_basic_slider_2' or @id='dx_captcha_basic_slider_3' or @id='dx_captcha_basic_slider_4' or @id='dx_captcha_basic_slider_5' or @id='dx_captcha_basic_slider_6' or @id='dx_captcha_basic_slider_7' or @id='dx_captcha_basic_slider_8']")));
|
124 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
| 125 |
slideButton = driver.findElement(By.xpath("//*[@id='dx_captcha_basic_slider_1' or @id='dx_captcha_basic_slider_2' or @id='dx_captcha_basic_slider_3' or @id='dx_captcha_basic_slider_4' or @id='dx_captcha_basic_slider_5' or @id='dx_captcha_basic_slider_6' or @id='dx_captcha_basic_slider_7' or @id='dx_captcha_basic_slider_8']"));
|
125 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
| 126 |
//System.out.println("Slide button - " + slideButton);
|
126 |
//System.out.println("Slide button - " + slideButton);
|
| 127 |
System.out.println("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
127 |
System.out.println("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
| 128 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
128 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
| 129 |
.moveByOffset(1, 0)//.pause(2000)
|
129 |
.moveByOffset(1, 0)//.pause(2000)
|
| 130 |
.perform();
|
130 |
.perform();
|
| Line 158... |
Line 158... |
| 158 |
} catch (Exception notFailedException) {
|
158 |
} catch (Exception notFailedException) {
|
| 159 |
System.out.println("Success at attempt " + counter);
|
159 |
System.out.println("Success at attempt " + counter);
|
| 160 |
//List<WebElement> warrantyDateElements = driver.findElements(By.className("warranty-service--result_info__dateValue"));
|
160 |
//List<WebElement> warrantyDateElements = driver.findElements(By.className("warranty-service--result_info__dateValue"));
|
| 161 |
//WebElement activationTimeElement = driver.findElement(By.xpath("//*[contains(text(), 'UTC+5.5') or contains(text(), 'Non-Activate')]"));
|
161 |
//WebElement activationTimeElement = driver.findElement(By.xpath("//*[contains(text(), 'UTC+5.5') or contains(text(), 'Non-Activate')]"));
|
| 162 |
WebElement warrantyStatus = driver.findElement(By.xpath(
|
162 |
WebElement warrantyStatus = driver.findElement(By.xpath(
|
| 163 |
"//label[text()='Estimated Warranty Expiration Date']/following-sibling::div/span"
|
163 |
"//label[text()='Estimated Warranty Expiration Date']/following-sibling::div/span | //h1[contains(@class, 'title')]"));
|
| 164 |
));
|
- |
|
| 165 |
|
164 |
|
| 166 |
|
165 |
|
| 167 |
//TODO: IF not found activationElement
|
166 |
//TODO: IF not found activationElement
|
| 168 |
if (warrantyStatus != null) {
|
167 |
if (warrantyStatus != null) {
|
| 169 |
String activationDateString = warrantyStatus.getText().trim();
|
168 |
String activationDateString = warrantyStatus.getText().trim();
|
| Line 192... |
Line 191... |
| 192 |
System.out.println("Failed = " + counter + " ----------" + e.getMessage());
|
191 |
System.out.println("Failed = " + counter + " ----------" + e.getMessage());
|
| 193 |
}
|
192 |
}
|
| 194 |
}
|
193 |
}
|
| 195 |
}
|
194 |
}
|
| 196 |
System.out.println("After circles conditions");
|
195 |
System.out.println("After circles conditions");
|
| 197 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_wrapper_1")));
|
196 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
| 198 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_slider_1")));
|
197 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
| 199 |
slideButton = driver.findElement(By.id("dx_captcha_basic_slider_1"));
|
198 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
| 200 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
199 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
| 201 |
System.out.println("Ending Do" + counter++);
|
200 |
System.out.println("Ending Do" + counter++);
|
| 202 |
|
201 |
|
| 203 |
} while (captchaNotBroken && counter <= 20);
|
202 |
} while (captchaNotBroken && counter <= 20);
|
| 204 |
System.out.println("Counter reached upto 20");
|
203 |
System.out.println("Counter reached upto 20");
|