Imacro脚本在Firefox扩展中无法执行,FRAME定位环节报错求助
Hey there, let's figure out why your iMacros script is getting stuck on the FRAME NAME="isolatedWorkArea" step when moving from the standalone iMacros Browser v12 to the Firefox extension v9.0.3. Older versions of the Firefox iMacros extension have some key differences in how they handle frames, so let's break this down.
Environment Details
- iMacros Browser: v12.0.501.6698
- Firefox: v52.8.0 (ESR)
- iMacros for Firefox: v9.0.3
Your Original Script
VERSION BUILD=9030808 RECORDER=FX SET !VAR0 "EPANOTICESRemedial{{!NOW:yyyymmdd}}" SET !VAR1 "EPANOTICESPC{{!NOW:yyyymmdd}}" TAB T=1 TAB CLOSEALLOTHERS URL GOTO=http://www.epa.vic.gov.au/our-work/compliance-and-enforcement/remedial-notices-and-directions TAG POS=1 TYPE=A ATTR=TXT:Search<SP>for<SP>a<SP>remedial<SP>notice TAB T=2 FRAME NAME="isolatedWorkArea" TAG POS=4 TYPE=IMG ATTR=SRC:https://crm.epa.vic.gov.au/SAP/BC/BSP/SAP/ZTHTMLB_STYLES/nova_epa/images/down.gif TAG POS=1 TYPE=A ATTR=TXT:All TAG POS=1 TYPE=B ATTR=TXT:Search ONDOWNLOAD FOLDER=L:\Data\Victoria\EPA<SP>Pollution<SP>Notices\Daily<SP>Downloads FILE= {{!VAR0}} WAIT=YES TAG POS=1 TYPE=IMG ATTR=SRC:https://crm.epa.vic.gov.au/SAP/BC/BSP/SAP/ZTHTMLB_STYLES/nova_epa/images/tableView/excel_download.gif TAB T=1 TAB CLOSEALLOTHERS URL GOTO=http://www.epa.vic.gov.au/our-work/compliance-and-enforcement/remedial-notices-and-directions TAG POS=1 TYPE=A ATTR=TXT:Search<SP>for<SP>a<SP>PC<SP>PAN TAB T=2 FRAME NAME="isolatedWorkArea" TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:C7_W22_V23_V24_onlinetranstype_max_hits CONTENT=50 TAG POS=1 TYPE=A ATTR=TXT:All TAG POS=1 TYPE=A ATTR=ID:C7_W22_V23_V24_SEARCH_BTN ONDOWNLOAD FOLDER=L:\Data\Victoria\EPA<SP>Pollution<SP>Notices\Daily<SP>Downloads FILE= {{!VAR1}} WAIT=YES TAG POS=1 TYPE=IMG ATTR=SRC:https://crm.epa.vic.gov.au/SAP/BC/BSP/SAP/ZTHTMLB_STYLES/nova_epa/images/tableView/excel_download.gif
Why This Is Failing
The main issue here is that the v9.0.3 Firefox iMacros extension has less robust frame targeting logic compared to the standalone v12 browser. Here are the most likely culprits:
- Frame Name Recognition: The extension might not reliably pick up frames by their
NAMEattribute, especially if the frame loads asynchronously or is nested. - Timing Gaps: The standalone browser automatically waits for frames to load, but the Firefox extension might try to interact with the frame before it's fully rendered.
- Syntax Compatibility: Some syntax that works in v12 (like extra spacing in variable assignments) might trip up the older extension.
Fixes to Try
Let's go through actionable steps to resolve this:
1. Target Frames by Position Instead of Name
If the extension doesn't recognize the frame by name, switch to targeting it by its position in the page. Replace FRAME NAME="isolatedWorkArea" with FRAME POS=1 (adjust the position number if there are multiple frames on the page).
Modified snippet example:
TAB T=2 FRAME POS=1 // Replaced NAME with POS here TAG POS=4 TYPE=IMG ATTR=SRC:https://crm.epa.vic.gov.au/SAP/BC/BSP/SAP/ZTHTMLB_STYLES/nova_epa/images/down.gif
2. Add Explicit Wait Commands
Force the script to wait for the frame to load before interacting. Add a WAIT SECONDS=X line right after switching to the new tab:
TAB T=2 WAIT SECONDS=3 // Give the frame 3 seconds to fully load FRAME NAME="isolatedWorkArea"
3. Clean Up Variable Syntax
Double-check your variable declarations to remove any extra spaces that might cause issues in the older extension:
SET !VAR0 "EPANOTICESRemedial{{!NOW:yyyymmdd}}" SET !VAR1 "EPANOTICESPC{{!NOW:yyyymmdd}}"
(Ensure there are no spaces between FILE= and the variable in your ONDOWNLOAD lines too.)
4. Debug with the Firefox Recorder
Use the iMacros recorder in Firefox to manually record the steps involving the frame. Play back the recorded snippet—this will show you exactly how the extension expects to target the frame (often using POS instead of NAME).
5. Check for Nested Frames
If isolatedWorkArea is inside another frame, you'll need to target the parent frame first, then the child:
TAB T=2 FRAME POS=1 // Parent frame FRAME POS=1 // Child frame (isolatedWorkArea)
Final Notes
Start with adding a wait and switching to frame position targeting—these two fixes resolve most frame-related issues in the older Firefox iMacros extension. The standalone browser is more forgiving, but small adjustments to timing and targeting should get your script running smoothly in Firefox.
内容的提问来源于stack exchange,提问作者Jay Edwards

