Subversion Repositories SmartDukaan

Rev

Rev 34413 | Rev 34423 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34413 Rev 34415
Line 77... Line 77...
77
        WebDriverWait wait5Sec = new WebDriverWait(driver, 4);
77
        WebDriverWait wait5Sec = new WebDriverWait(driver, 4);
78
        WebElement slideButton;
78
        WebElement slideButton;
79
        Actions actionProvider = new Actions(driver);
79
        Actions actionProvider = new Actions(driver);
80
        do {
80
        do {
81
            driver.get("https://support.oppo.com/in/warranty-check/");
81
            driver.get("https://support.oppo.com/in/warranty-check/");
-
 
82
            try {
82
            driver.findElement(By.cssSelector(".cp-cookie-tip a.close")).click();
83
                driver.findElement(By.cssSelector(".cp-cookie-tip a.close")).click();
-
 
84
            } catch (Exception e) {
-
 
85
                try {
-
 
86
                    System.out.println("Cookie not found");
-
 
87
                } catch (Exception e1) {
-
 
88
                }
-
 
89
            }
-
 
90
 
83
            for (int i = 0; i < remainingImeis.size(); i++) {
91
            for (int i = 0; i < remainingImeis.size(); i++) {
84
                String imei = remainingImeis.get(i);
92
                String imei = remainingImeis.get(i);
85
                try {
93
                try {
86
                    System.out.println("Starting fresh with new IMEI " + imei);
94
                    System.out.println("Starting fresh with new IMEI " + imei);
87
                    if (driver.findElement(By.className("el-input__inner")).getAttribute("value").length() > 0) {
95
                    if (driver.findElement(By.className("el-input__inner")).getAttribute("value").length() > 0) {
Line 137... Line 145...
137
                                        wait5Sec.until(ExpectedConditions.visibilityOfElementLocated(By.className("dx_captcha_basic_bar-inform")));
145
                                        wait5Sec.until(ExpectedConditions.visibilityOfElementLocated(By.className("dx_captcha_basic_bar-inform")));
138
                                        System.out.println("Failed = " + counter);
146
                                        System.out.println("Failed = " + counter);
139
                                    } catch (Exception notFailedException) {
147
                                    } catch (Exception notFailedException) {
140
                                        System.out.println("Success  at attempt " + counter);
148
                                        System.out.println("Success  at attempt " + counter);
141
                                        //List<WebElement> warrantyDateElements = driver.findElements(By.className("warranty-service--result_info__dateValue"));
149
                                        //List<WebElement> warrantyDateElements = driver.findElements(By.className("warranty-service--result_info__dateValue"));
142
                                        WebElement activationTimeElement = driver.findElement(By.xpath("//*[contains(text(), 'UTC+5.5')]"));
150
                                        WebElement activationTimeElement = driver.findElement(By.xpath("//*[contains(text(), 'UTC+5.5')  or contains(text(), 'Non-Activate')]"));
143
//TODO: IF not found activationElement
151
//TODO: IF not found activationElement
144
                                        if (activationTimeElement != null) {
152
                                        if (activationTimeElement != null) {
145
                                            String activationDateString = activationTimeElement.getText().trim();
153
                                            String activationDateString = activationTimeElement.getText().trim();
146
                                            System.out.println("Date --  " + activationDateString);
154
                                            System.out.println("Date --  " + activationDateString);
147
                                            try {
155
                                            try {
148
                                                dateMap.put(imei, LocalDate.parse(activationDateString.split(" ")[0], DateTimeFormatter.ofPattern("dd/MM/yyyy")));
156
                                                dateMap.put(imei, LocalDate.parse(activationDateString.split(" ")[0], DateTimeFormatter.ofPattern("dd/MM/yyyy")));
-
 
157
                                                System.out.println("Date --  " + activationDateString);
149
                                            } catch (Exception e) {
158
                                            } catch (Exception e) {
150
                                                dateMap.put(imei, null);
159
                                                dateMap.put(imei, null);
151
                                            }
160
                                            }
152
                                        } else {
161
                                        } else {
153
                                            System.out.println("Could not capture date");
162
                                            System.out.println("Could not capture date");
154
                                            dateMap.put(imei, null);
163
                                            dateMap.put(imei, null);
155
                                        }
164
                                        }
-
 
165
                                        if(dateMap.size()==imeis.size()) {
-
 
166
                                            driver.close();
-
 
167
                                            driver.quit();
-
 
168
                                            return dateMap;
-
 
169
                                        }
156
                                        WebElement checkAgainButton = driver.findElement(By.className("c-btn"));
170
                                        WebElement checkAgainButton = driver.findElement(By.className("c-btn"));
157
                                        captchaNotBroken = false;
171
                                        captchaNotBroken = false;
158
                                        checkAgainButton.click();
172
                                        checkAgainButton.click();
159
                                        break;
173
                                        break;
160
                                    }
174
                                    }