I was wondering if there are any plans on implementing a regex text search? I really love the OCR functionality, in some cases it has caused a dramatic increase in script speed. If there were a way to search for even basic regular expressions it would be super useful.
Can you give us a specific example of the kind of searching you’d like to do and the situation where you’d use it? At this time we don’t have any specific plans to add regular expression capabilities, but there may be other approaches we could suggest. If there’s not currently a useful alternative, then understanding your specific need will help us when we are planning and prioritizing possible feature additions for the future.
Thanks! And it’s good to hear that the OCR functionality is working well for you!
I am testing a program that lists classes, however lots of classes have similar names:
Depending on the order of the list, when I search for Science, I will get which ever is at the top. With a regular expression I would be able to avoid this with \s?[^\d] at the end of the word Science. I currently search for class name and create a search box to the right of the word and verify that the area is blank. If it’s not, then I create a search box down and re-search for the class name and the blank area. This can lead to 3-4 searches before finding the correct class.
How can your text recognition working so well?
Are you testing web on PC, or mobile app on mobile device?
We have mobile app, but there is a TableView with a
list of news feed. We want to search for text, click on text.
But it can not consistently find the text.
How do you consistently search for text? Thank you.
We’re running primarily on Mac desktop systems. I’ve only found one pop-up that is a part of our program that the OCR can’t read. I believe it is because it’s an image that was not properly re-sized.
When testing on a PC we see a bit of a quality decrease in the OCR, however it is still very useful. I’ve been using it in the following formats:
If imagefound(Text:“ClassName”) then…
With default values, it seems to be working well. We haven’t tested other languages yet, but will be in a few months, I hope it works as well with other languages.
Ok so you just want to do something with class science not one that has anything behind it but even that would work using something like:
repeat with each item in everyimagelocation(text:“science”)
if last word in readtext(it) is “science” then moveto it
instead of using moveto you can use any other mouse command that you would need in your application
Thanks a lot. I also found that the text font maybe an issue.
For example, we created a script with click text “Settings” on Android.
It looks the same on iPhone. But click text “Settings” doesn’t run
on iPhone. So it seems that click on text no guarantee it can run
on different devices.
Are you running your script on the same Mac or different computer?
Do you need to modify the settings of text recognition? Such as font and
text size tolenrance.
@Jhnny: I hope that the abbreviated portion of your conditional statement looked like this:
If imagefound(Text:"ClassName") then Click foundImageLocation() end if
This saves the time involved in searching again for the thing that you just found so that you can click on it.
Joost’s approach to dealing with the class names is a good one and much simpler than your (clever) search box approach.
There are some things that you can do that would work a bit like a regular expression, but they are fairly brute force implementations and wouldn’t be quick, but you can for example say things like:
if the number of characters in myVar is 7 and the fifth character of myVar is a number then ...
That sort of thing will work in some scenarios.
Do you have layers of your application, or some popup?
If you have more than one layers in one page, do you need to do anything
to detect the text in the layer? For example, our app has navigation bar on the top, content in the middle, tab bar at the bottom. I consider it has 2~3 layers.
Do you need to do anything, or refocus to certain area to detect text? How about for handling popups?
You can isolate areas of the screen by specifying a rectangle to search. As of eggPlant v11.02 you can specify a rectangle with just 2 images representing opposite corners of the rectangle, for example:
Click (ImageName:"myImage", searchRectangle("UL_image", "LR_image"))
You can use coordinates if you know that will never change, such as when testing a mobile device:
MoveTo(ImageName:"someImage", searchRectangle(0,200, 320,450))
You mention popups. Do you mean unexpected messages that pop up that aren’t part of your tests? If so, you’ll want to look at the built-in Omega13 script (type “Omega13” into the text field at the bottom of the Run window and hit return) that overrides the image-based commands so that if an image is not found, you can check to see whether a predefined condition exists or simply take action to bring focus back to your application. To use it you first need to create a script called “AttemptRecovery”. This script must be written to either deal with a specific popup (or popups) or to bring your application back to the foreground; as such, creating the script may be an iterative process as new conditions arise. Once you have the script written, you can add the following line to any other script:
start using Omega13
Once you do that, all subsequent commands and functions that target images will be overridden such that if they fail with an “image not found” condition, they will call out to your AttemptRecovery script. That script is then executed and can try to resolve any known issues that would prevent the image from being found before returning control to the Omega13 script, which then tries again to locate the image and if successful, your script continues as though no problem had occurred.