← Back to team overview

sikuli-driver team mailing list archive

[Question #676619]: Getting text(date) from image that changes everyday

 

New question #676619 on Sikuli:
https://answers.launchpad.net/sikuli/+question/676619

I am trying to get text from image. Text is the date that changes every hour. Sikuli is getting the text what is in image not on the application.

I am comparing the Text(Date) string with the  my calculated date. As the Date from the application changes often my scripts are failing.

Here is the logic:

  try {

            //Extract Donor's Status text from the region
            Settings.OcrTextRead = true;
            Settings.OcrTextSearch = true;

            screen.wait(txtImage, 10);
            String extractText = screen.find(txtImage).text();
            extractText = extractText.replaceAll("[a-zA-Z]","/");
           // extractText = extractText.substring(3);
           Date date1 = new SimpleDateFormat(US_DATE_FORMAT_STRING).parse(extractText);
            TestEnvironment.get().getTestLogger().log("Eligibility Date: " + extractText);

            LocalDate today = LocalDate.now();
            LocalDate drawdate = null;

            if (period.toLowerCase().contains("today")){
                drawdate =LocalDate.now();
            } else if (period.toLowerCase().contains("week")){
                drawdate = today.minus(1, ChronoUnit.WEEKS);
            } else if (period.toLowerCase().contains("month")){
                drawdate = today.minus(1, ChronoUnit.MONTHS);
            }else {
                throw new IllegalArgumentException(period);
            }

            LocalDate eligibilityDate = drawdate.plus(days, ChronoUnit.DAYS);
            TestEnvironment.get().getTestLogger().log("Calculated Eligibility Date: " + eligibilityDate);

            TestEnvironment.get().getErrorCollector().checkThat("Eligibility Date:", extractText, is(equalTo(eligibilityDate.format(US_DATE_FORMAT))));

        } catch (FindFailed | ParseException  error) {
            TestEnvironment.get().getErrorCollector().addError(error);
        }

extractText  changes often in my application, I have to take screenshot when ever it changes and run my scripts. Can you please suggest me any other alternatives to get dynamic text from application instead of the captured image.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.