imacros javascript workaround

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
florina
Posts: 8
Joined: Mon Jun 19, 2017 12:33 pm

imacros javascript workaround

Post by florina » Tue Jun 20, 2017 5:36 pm

Hello.
I have the following code:
I'm using iMacros 9.0 for Firefox on Firefox 54.0 (64 bit)

Code: Select all

var macro1;
var macro2;
macro1 =  "CODE:";
macro1 +=  "TAB T=1" + "\n"; 
macro1 +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
macro1 +=  "SET !DATASOURCE links2.csv" + "\n"; 
macro1 +=  "SET !LOOP 257" + "\n"; 
macro1 +=  "SET !DATASOURCE_COLUMNS 3" + "\n"; 
macro1 +=  "SET !DATASOURCE_LINE {{i}}" + "\n"; 
macro1 +=  "URL GOTO={{!COL3}}" + "\n"; 
macro1 +=  "'description" + "\n"; 
macro1 +=  "FRAME F=1" + "\n"; 
macro1 +=  "TAG POS=1 TYPE=TD ATTR=ID:bottom-d" + "\n"; 
macro1 +=  "TAG POS=R-2 TYPE=TR ATTR=TXT:* EXTRACT=HTM" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL1}}" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL2}}" + "\n"; 
macro1 +=  "SAVEAS TYPE=EXTRACT FOLDER=* FILE=desc.csv" + "\n"; 
macro1 +=  "WAIT SECONDS=3" + "\n"; 

macro2 =  "CODE:";
macro2 +=  "TAB T=1" + "\n"; 
macro2 +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
macro2 +=  "SET !DATASOURCE links2.csv" + "\n"; 
macro2 +=  "SET !LOOP 257" + "\n"; 
macro2 +=  "SET !DATASOURCE_COLUMNS 3" + "\n"; 
macro2 +=  "SET !DATASOURCE_LINE {{i}}" + "\n"; 
macro2 +=  "URL GOTO={{!COL3}}" + "\n"; 
macro2 +=  "'description" + "\n"; 
macro2 +=  "FRAME F=2" + "\n"; 
macro2 +=  "TAG POS=1 TYPE=DIV ATTR=ID:pictures EXTRACT=HTM" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL1}}" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL2}}" + "\n"; 
macro2 +=  "SAVEAS TYPE=EXTRACT FOLDER=* FILE=desc.csv" + "\n"; 
macro2 +=  "WAIT SECONDS=3" + "\n"; 

var i=0;

if (window.document.getElementById('first_id') !== null){
	i++;
	iimSet("i",i);
	iimPlay(macro1);
	}
else if (window.document.getElementById('second_id') !== null){
	i++;
	iimSet("i",i);
	iimPlay(macro1);
	}
I get the following error:

Code: Select all

Error: Accessing content window is not supported in multiprocess Firefox, line 208
What is the workaround for this situation?
Basically I need to check if a certain element id exists on the page and run the proper macro.
I only put 2 possible cases, but there may more. In fact strike that, it's certain there will be more than two cases.
Thank you for your time
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: imacros javascript workaround

Post by chivracq » Tue Jun 20, 2017 6:51 pm

florina wrote:Hello.
I have the following code:
I'm using

Code: Select all

iMacros 9.0 for Firefox on Firefox 54.0 (64 bit)

Code: Select all

var macro1;
var macro2;
macro1 =  "CODE:";
macro1 +=  "TAB T=1" + "\n"; 
macro1 +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
macro1 +=  "SET !DATASOURCE links2.csv" + "\n"; 
macro1 +=  "SET !LOOP 257" + "\n"; 
macro1 +=  "SET !DATASOURCE_COLUMNS 3" + "\n"; 
macro1 +=  "SET !DATASOURCE_LINE {{i}}" + "\n"; 
macro1 +=  "URL GOTO={{!COL3}}" + "\n"; 
macro1 +=  "'description" + "\n"; 
macro1 +=  "FRAME F=1" + "\n"; 
macro1 +=  "TAG POS=1 TYPE=TD ATTR=ID:bottom-d" + "\n"; 
macro1 +=  "TAG POS=R-2 TYPE=TR ATTR=TXT:* EXTRACT=HTM" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL1}}" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL2}}" + "\n"; 
macro1 +=  "SAVEAS TYPE=EXTRACT FOLDER=* FILE=desc.csv" + "\n"; 
macro1 +=  "WAIT SECONDS=3" + "\n"; 

macro2 =  "CODE:";
macro2 +=  "TAB T=1" + "\n"; 
macro2 +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
macro2 +=  "SET !DATASOURCE links2.csv" + "\n"; 
macro2 +=  "SET !LOOP 257" + "\n"; 
macro2 +=  "SET !DATASOURCE_COLUMNS 3" + "\n"; 
macro2 +=  "SET !DATASOURCE_LINE {{i}}" + "\n"; 
macro2 +=  "URL GOTO={{!COL3}}" + "\n"; 
macro2 +=  "'description" + "\n"; 
macro2 +=  "FRAME F=2" + "\n"; 
macro2 +=  "TAG POS=1 TYPE=DIV ATTR=ID:pictures EXTRACT=HTM" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL1}}" + "\n"; 
macro2 +=  "ADD !EXTRACT {{!COL2}}" + "\n"; 
macro2 +=  "SAVEAS TYPE=EXTRACT FOLDER=* FILE=desc.csv" + "\n"; 
macro2 +=  "WAIT SECONDS=3" + "\n"; 

var i=0;

if (window.document.getElementById('first_id') !== null){
	i++;
	iimSet("i",i);
	iimPlay(macro1);
	}
else if (window.document.getElementById('second_id') !== null){
	i++;
	iimSet("i",i);
	iimPlay(macro1);
	}
I get the following error:

Code: Select all

Error: Accessing content window is not supported in multiprocess Firefox, line 208
What is the workaround for this situation?
Basically I need to check if a certain element id exists on the page and run the proper macro.
I only put 2 possible cases, but there may more. In fact strike that, it's certain there will be more than two cases.
Thank you for your time
Euh..., "v9.0" for FF does not exist, I reckon you mean v9.0.3...
Hum, and OS is missing from your FCI, even if it won't play a role in this Case...

But, yep, known "Limitation" for v9.0.3 for FF since FF48 I think, which prevents iMacros from accessing the DOM with your 'window.document.getElementById()' Syntax, you need to disable 'Multi-Processing' in FF... (Search the Forum (or the FF/Mozilla Support Site) if you don't know how to do it, we have several Threads on the Forum from a few months ago...)

Better Solution is actually to revert to v8.9.7 for FF (still works on FF54) which still supports the Syntax you are using, and is more stable than v9.0.3... :idea:

Another way to achieve what you want would actually be to let iMacros (from the '.iim' part) check if your Element exists (using the 'EXTRACT' Mechanism)...
- (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