Finding an Element

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
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
ramhanuman
Posts: 1
Joined: Thu Jan 09, 2014 12:39 am

Finding an Element

Post by ramhanuman » Thu Jan 09, 2014 1:44 am

I'm writing a C++ script with iMacro and basically I want to go login to a website, go to a particular page and look for an element. Under normal circumstances the element won't be there, but the script will continuously refresh the page until the element shows up in which case it will stop refreshing and select it. The element is a checkbox.

I've already written all the code to do most of what I said but I just don't know how to find an element. I already know the element is this:

Code: Select all

TAG POS=8 TYPE=INPUT:CHECKBOX FORM=ACTION:/pls/PROD/bwykfreg.P_AltPin1?deviceType=C ATTR=NAME:sel_crn CONTENT=YES
So in my C++ I want something like this:

Code: Select all

if (element)
	//if checkbox exist then select it
else
	//if checkbox does not exist then refresh the page
Is there an iMacro function that allows me to SEARCH for an element and return true of false? Or something that is similar.

***EDIT1***
I've found this and modified it to fit my code a little so this is what I have:

Code: Select all

int timeout = 60;
ref class ManagedGlobals {
public:
	static iMacros::AppClass^ app;
};

bool doesElementExist() {
	iMacros::Status stat;
	ManagedGlobals::app->iimDisplay("Searching for element", timeout);
	stat = ManagedGlobals::app->iimPlay("CODE:SET !TIMEOUT_TAG 1\n"
		+ "CODE:TAG POS=8 TYPE=INPUT:CHECKBOX FORM=ACTION:/pls/PROD/bwykfreg.P_AltPin1?deviceType=C ATTR=NAME:sel_crn CONTENT=YES", timeout);
	ManagedGlobals::app->iimDisplay(stat.ToString(), timeout);
	ManagedGlobals::app->iimPlay("CODE:WAIT SECONDS=10", timeout);
	if (stat != iMacros::Status::sOk) {
		ManagedGlobals::app->iimDisplay("Didn't find it", timeout);
		return false;		
	}
	ManagedGlobals::app->iimDisplay("Found it", timeout);
	return true;
}
The stat variable is returning error -1100. Which according to this means
Load Failed: Failed to load the macro (syntax or I/O error) (Found wrong macro command while loading file).
Does anyone know what that means?
Post Reply