Subversion Repositories SmartDukaan

Rev

Rev 36306 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36306 Rev 36583
Line 286... Line 286...
286
    private double[] getMatCircles2(WebDriver driver, String fileName) throws Exception {
286
    private double[] getMatCircles2(WebDriver driver, String fileName) throws Exception {
287
        File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
287
        File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
288
        BufferedImage fullImg = ImageIO.read(screenshot);
288
        BufferedImage fullImg = ImageIO.read(screenshot);
289
 
289
 
290
        // Get the location of element on the page
290
        // Get the location of element on the page
291
        WebElement imageElement = driver.findElement(By.id("dx_captcha_basic_bg_1"));
291
        WebElement imageElement = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_bg_')]"));
292
        Point point = imageElement.getLocation();
292
        Point point = imageElement.getLocation();
293
 
293
 
294
        // Get width and height of the element
294
        // Get width and height of the element
295
        int eleWidth = imageElement.getSize().getWidth();
295
        int eleWidth = imageElement.getSize().getWidth();
296
        int eleHeight = imageElement.getSize().getHeight();
296
        int eleHeight = imageElement.getSize().getHeight();
Line 304... Line 304...
304
        File screenshotLocation = new File(fileName);
304
        File screenshotLocation = new File(fileName);
305
        FileUtils.copyFile(screenshot, screenshotLocation);
305
        FileUtils.copyFile(screenshot, screenshotLocation);
306
 
306
 
307
        Mat src = Imgcodecs.imread(fileName);
307
        Mat src = Imgcodecs.imread(fileName);
308
        if (src.empty()) {
308
        if (src.empty()) {
309
            System.err.println("Cannot read image: " + fileName);
309
            LOGGER.warn("Cannot read image: {}", fileName);
310
            new File(fileName).delete();
310
            new File(fileName).delete();
311
            return null;
311
            return null;
312
        }
312
        }
313
 
313
 
314
        Mat gray = new Mat();
314
        Mat gray = new Mat();