How to get Dynamic text using Sikuli

91 views Asked by At

I am new to Sikuli and trying to automate a Mainframe application. The issue is that I have a Combination of both Number and text based Reg Ctrl. As Shown in the image. Everytime I run it, it changes dynamically. Is there a way of getting the text of it.

enter image description here

File srcRSN= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

    FileUtils.copyFile(srcRSN, new File("C:\\Users\\za42\\Desktop\\GRS\\Sikuli\\screenshot1.png"));

    File RSNScreenshot = new File("C:\\Users\\za42\\Desktop\\GRS\\Sikuli\\screenshot1.png");

    ITesseract RSNScreenshotInstance = new Tesseract(); 
    RSNScreenshotInstance.setDatapath("C:\\Users\\za42\\Desktop\\GRS\\Sikuli\\Tess4J-3.4.8-src\\Tess4J\\tessdata");

    String resultRSN = null;

    try {

        resultRSN = instance.doOCR(RSNScreenshot);

        System.out.println(resultRSN);

    } catch (TesseractException e) {

        System.err.println(e.getMessage());

    }

    String RSN = resultRSN.substring(578,581);

    System.out.println(RSN);

Can we use any other way rather taking the screenshot first then loaading and extracting the data. Is there a Direct way of reading it on the screen itself.

0

There are 0 answers