Image Recognition to check if image is not present?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
twe69
Posts: 3
Joined: Wed Oct 04, 2017 10:27 am

Image Recognition to check if image is not present?

Post by twe69 » Wed Oct 04, 2017 10:31 am

Hello everyone, my first time here and using iMacros.

I have successfully created my first macro to recognise if a permission, in our software, has been applied by using Image Recognition against an icon. However is there a way to test to make sure that the same image is not recognised on the webpage, i.e. when the permission has been removed?

I am using IE 11 and the last version of iMacros v11.

Thanks!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Image Recognition to check if image is not present?

Post by chivracq » Wed Oct 04, 2017 11:52 am

twe69 wrote:

Code: Select all

IE 11 and the last version of iMacros v11.
Hello everyone, my first time here and using iMacros.

I have successfully created my first macro to recognise if a permission, in our software, has been applied by using Image Recognition against an icon. However is there a way to test to make sure that the same image is not recognised on the webpage, i.e. when the permission has been removed?

I am using IE 11 and the last version of iMacros v11.

Thanks!
Hum, "last/latest" is always a bit vague, always mention the exact Version...
=> Probably iMacros for IE v11.5...? + OS not mentioned...?
And hum, "first Macro" using v11 or v11.5 sounds a bit strange as well, sbd using iMacros for the first time would have downloaded the latest Version which is now v12.0... :?

Well, '!IMAGEX' + '!IMAGEY' hold the Coordinates of your Image if it has been found..., then you can run a Check using 'EVAL()' on those Values for any Decision/further Processing you then want to make...

But, hum..., using Image Recognition and 'IMAGESEARCH' to check for the Presence of an Icon sounds a bit cumbersome and "heavy Canon to kill a Fly" to me, ah-ah...! :shock:
Unless your Image/Icon is embedded into some Flash Object, you could better check for it from its 'EXTRACT=HREF', I would think..., and maybe combined with Relative Positioning if that Icon might appear several times on the same Page to make sure you are targeting the one that you want... That's simpler, more reliable, and quicker I would think... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
twe69
Posts: 3
Joined: Wed Oct 04, 2017 10:27 am

Re: Image Recognition to check if image is not present?

Post by twe69 » Wed Oct 04, 2017 1:19 pm

Hi chivracq thanks for the quick reply.

I am using iMacro Browser v11.5.499.3066 - Unfortunately only version 11 has been licensed by my company and not the newest v12. This includes the plugin for IE11.
Also using Windows 10 Professional 64 bit.

The reason why I think the image recognition would be better is because several other testers could play around with the settings, and so the icon may be placed elsewhere in the menu due to various permissions being switched on or off.

Is there another method that you can think of besides looking at a specific position on the page for the icon?

The icon has these attributes:

title="Favourite" id="Favourite" href="javascript:onClick=ExpandQATab('Favourite','/Favourite/Favourite')">

From what you said above is there a command such as EXTRACT=id

Thanks!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Image Recognition to check if image is not present?

Post by chivracq » Wed Oct 04, 2017 2:13 pm

twe69 wrote:Hi chivracq thanks for the quick reply.

I am using iMacro Browser v11.5.499.3066 - Unfortunately only version 11 has been licensed by my company and not the newest v12. This includes the plugin for IE11.
Also using Windows 10 Professional 64 bit.

The reason why I think the image recognition would be better is because several other testers could play around with the settings, and so the icon may be placed elsewhere in the menu due to various permissions being switched on or off.

Is there another method that you can think of besides looking at a specific position on the page for the icon?

The icon has these attributes:

Code: Select all

title="Favourite" id="Favourite" href="javascript:onClick=ExpandQATab('Favourite','/Favourite/Favourite')">
From what you said above is there a command such as EXTRACT=id

Thanks!
Ah OK, FCI makes sense...

Hum, and if several Testers might be "playing" with the Settings or the Page, that makes 'IMAGESEARCH' even more "unreliable" unless all those Testers are all using the same one and only Computer in your Company/Department, ah-ah...!!
Yep...!, OK, I guess they all have their own PC/Laptop, but they all need to have the Control Image stored somewhere on their PC, at probably some \[USER]\ dependent Location, which means they also need to adapt the Path to the File in the Script... That's "cruising for trouble" in my Opinion...
And yep, you can store the Control Image in some Shared Network Directory, but hum, I still find it cumbersome, Network Shares are not always available, if you try to run the Script from a Remote Location or from Home, the Script will fail, etc...

Well about "Is there another method...?", I already mentioned using 'EXTRACT=HREF' or 'EXTRACT=whatever' on the Icon/Image.
As you are on iMB/IE, yep, "Extracting on Custom Attributes" (only supported on iMB/IE from v10.2) with your "EXTRACT=ID" could be an Idea (I've never had a chance to use/test it as I only use the Free Add-on (mostly) for FF), but the same "Favourite" Data is also contained in the 'TITLE' Attribute and 'EXTRACT=TITLE' (supported on all Browsers) would yield the same Info/Value. Or 'EXTRACT=HTM' which will contain the complete HTML Data, or 'EXTRACT=HREF' like I already mentioned, but you would need to check once what exact String will that 'EXTRACT=HREF' return as Relative Paths get "derelatived" in the EXTRACT Process, even if that probably won't make a Difference as you would use some "if ('{{!EXTRACT}}'!='#EANF#'){...;}" Check in your 'EVAL()', then you don't care if a Path is Relative or not...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
twe69
Posts: 3
Joined: Wed Oct 04, 2017 10:27 am

Re: Image Recognition to check if image is not present?

Post by twe69 » Wed Oct 04, 2017 3:54 pm

From what I understand iMacro doesn't support IF statements? So is that JavaScript?

I shall play around with the 'EXTRACT' option and see if that is a better solution that the 'IMAGESEARCH' thanks!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Image Recognition to check if image is not present?

Post by chivracq » Wed Oct 04, 2017 4:19 pm

twe69 wrote:From what I understand iMacro doesn't support IF statements? So is that JavaScript?

I shall play around with the 'EXTRACT' option and see if that is a better solution that the 'IMAGESEARCH' thanks!
Yep, 'IF' Statements are "normally" only supported in '.js' Script in JavaScript (only iMacros for FF) or as you are using iMB, you can use any Programming Language like VB/Python/C++/C#/etc supported by the Scripting Interface but you can still achieve some "basic" Conditional Logic in pure '.iim' using (a Mix of) Relative Positioning, '!ERRORIGNORE', '!TIMEOUT_xxx' and mostly 'EVAL()' where JavaScript is natively supported on all 4 Browsers...
And well, when I say "basic", the Limit is your own "Creativity", I only use pure '.iim' myself even if I'm on FF (I don't use any '.js' Scripts), and my Scripts probably do more "Advanced" and complex "Things" than everything I've ever seen posted on the Forum in '.js'...
Have a look at the following Thread where I've explained a bit my Method and the Techniques I use and where I maintain a bit a List of interesting/relevant Threads with different Applications/Examples...:
- Workarounds for Conditional Logic in Macro Code :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply