How to test that a tag does NOT exist?

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
bearaman
Posts: 65
Joined: Fri Mar 02, 2007 5:26 pm

How to test that a tag does NOT exist?

Post by bearaman » Mon Sep 29, 2008 4:36 pm

Hi There,
I'd like to be able to check a web page and make sure that some link, text does NOT exist on the page. Maybe something like:
'

Code: Select all

NOT TAG POS=1 TYPE=DIV ATTR=TXT:Some Text
which would return an error is that tag was found.
Is there any way to do this?
Thanks,
B.
BrianR
Posts: 126
Joined: Wed Jun 11, 2008 4:13 pm

Re: How to test that a tag does NOT exist?

Post by BrianR » Mon Sep 29, 2008 6:04 pm

TAG POS=1 TYPE=SPAN ATTR=CLASS:pipagetitle&&TXT:Search<SP>Selection EXTRACT=TXT

If the word Search Selection is not there the imacro returns #EANF#

http://wiki.imacros.net/!EXTRACT
bearaman
Posts: 65
Joined: Fri Mar 02, 2007 5:26 pm

Re: How to test that a tag does NOT exist?

Post by bearaman » Thu Feb 26, 2009 2:42 pm

BrianR wrote:TAG POS=1 TYPE=SPAN ATTR=CLASS:pipagetitle&&TXT:Search<SP>Selection EXTRACT=TXT

If the word Search Selection is not there the imacro returns #EANF#
Thanks for that Brian. OK so I know I can access the #EANF# via getlastextract(). Now, how do I use that to make the macro pass and if found, raise an error?
Thanks,
John
BrianR
Posts: 126
Joined: Wed Jun 11, 2008 4:13 pm

Re: How to test that a tag does NOT exist?

Post by BrianR » Thu Feb 26, 2009 4:30 pm

In theory, yes. You should either receive valid text or the "Anchor Not Found" (#EANF#) text if the TAG exists. Otherwise it will be blank and then preform your logic.

Let us know how you make out.

Brian
bearaman
Posts: 65
Joined: Fri Mar 02, 2007 5:26 pm

Re: How to test that a tag does NOT exist?

Post by bearaman » Thu Feb 26, 2009 4:53 pm

Thanks Brian,
Actually, when I look at it, I phrased the question incorrectly. What I actually want is to test that a piece of text does not exist rather than a tag.
Let me clarify: What I want to do is to check that a page element has indeed been removed after it's been deleted. I'd like to try to click on that page element; if it's NOT found then the macros is passed; if it is found, then the macro must fail. This is the opposite to the normal behavior of the macros.
I know that a code of -301 is returned when a tage is not found but I just don't know how to use this to make the macro pass.
Any ideas would be welcome.
Thanks again,
John
Marcia, Tech Support

Re: How to test that a tag does NOT exist?

Post by Marcia, Tech Support » Fri Feb 27, 2009 10:04 am

Hello,

You could divide the macro at that point and, in the script test the return code (from iimPlay). If it is the right one (-301), go on to the next part of the macro, otherwise... handle.

Does it help you?
bearaman
Posts: 65
Joined: Fri Mar 02, 2007 5:26 pm

Re: How to test that a tag does NOT exist?

Post by bearaman » Fri Feb 27, 2009 11:32 am

Marcia, iOpus wrote:
You could divide the macro at that point and, in the script test for return code (from iimPlay). If it is the right one (-301), go on to the next part of the macro, otherwise... handle.
Thanks Marcia, that's what I want to do. I'm not too good at scripting, would you be able to give me a sample code snippet to show how this would work?
Many thanks for your time.
John
BrianR
Posts: 126
Joined: Wed Jun 11, 2008 4:13 pm

Re: How to test that a tag does NOT exist?

Post by BrianR » Fri Feb 27, 2009 3:17 pm

Here is a sample of a VBScript program. Copy this code into a file with the extension VBS. (ex: MyPgm.vbs)

Code: Select all

'Sample VBS Script Checking for Errors

'--------------------
' Initialize Object
'--------------------
Set iim1= CreateObject ("imacros")

'--------------------
'Initialize iMacros
'--------------------
iret = iim1.iimInit 

'--------------------
'Run First Macro
'--------------------
iret = iim1.iimPlay("My Macro 1")

'--------------------------
'Check for Error; If Found
'run a different Macro
'---------------------------
If iret = -301 Then 
	iret = iim1.iimPlay("My Macro 2")
End If

'--------------------
'Exit
'--------------------
iret = iim1.iimExit
Good Luck!

Brian
Post Reply