I'm using javascript and imacros to collect some data from a website and I have this line of code:
final_macro += "ADD !EXTRACT " + '"' + lager_col2[0].textContent + '"' + "\n";
When I ran my js in the browser I got this error:
Error: Accessing content window is not supported in multiprocess Firefox, line 208 (Error code: -991)
Should I be worried ? Is the use of textContent forbidden ?
The problem is that lager_col2[0] sometimes happen to be a link and I only want the text inside the link, not the tags and everything. So naturally I went with textContent. How could I get around this ?
Additionally, am I setting myself up for trouble when trying to access certain nodes with the use of window.document.getElementsByClassName?
Is it better to use iMACROS TAG POS/XPATH ?
The strange thing is I'm getting the exact same error that you are even down to the code line number. Obviously my JavaScript line numbers do not match yours. At first I thought the problems were caused by my recent upgrade to Firefox 48. But when I moved my imacros to another machine that is running Firefox 47 I got the exact same error as you.
Update: My workaround was to downgrade the Firefox iMacros extension from 9.0.3 to 8.9.7. Now my macro is working again with Firefox version 47 and iMacros version 8.9.7.
In similar cases I can suggest you one of my old workarounds with an additional function in order to get some window content:
var someContent = getSomeContent("document.getElementsByClassName('someclass')[0].textContent");
alert(someContent);
function getSomeContent(selector) {
var ret = iimPlayCode("URL GOTO=javascript:alert(" + selector + ");");
if (ret < 0)
return iimGetErrorText().match(/Dialog message: "([\s\S]*)",/)[1];
}
The idea seems to be helpful. But I haven't yet tested this script in multiprocess Firefox.
Reinstall plugin iMacros. It's helped me.
imacro does not support to access dom element please go back to older version of imacro older than imacro 9.
Firefox > 47.0.1 and iMacros > 8.9.7 not supported (because Firefox architecture changed)
Solve:
STEP 1. Remove add-on imacros if installed.
STEP 2. Uninstall Firefox.
STEP 3. Follow this link for download Firefox version Firefox 47.0.1. https://download-installer.cdn.mozilla.net/pub/firefox/releases/47.0.1/win32/en-US/Firefox%20Setup%2047.0.1.exe or this link https://support.mozilla.org/en-US/kb/install-older-version-of-firefox
STEP 4. Install Firefox 47.0.1 and after launch Firefox visit " about:support " .
STEP 5. You can see button "Refresh Firefox" click it and restart Firefox.
STEP 6. Follow this link to download iMacros version 8.9.7. https://addons.mozilla.org/en-US/firefox/addon/imacros-for-firefox/versions/
Related
I am listening to a server event via a javascript function on my HTML file, which outputs the server answer in the console tab. Since I need to pass this answer to a delphi application, I made the server answer "visible" via a div container. This works fine on Firefox, but on IE the output is not shown. I have then tried to utilize the value of a textarea, which also works on Firefox but not on IE.
I really wonder why it is so hard to get a console output visible on IE?
document.getElementById('my_div_container').innerHTML = JSON.stringify(my_data_I_want_to_see, null, 4);
document.getElementById('my_textarea').value = JSON.stringify(my_data_I_want_to_see, null, 4);
The above lines show a result on Firefox, but on IE there is no output at all. How can I get my data visible on IE?
I found the root cause why IE did not show any console output. I just found out, that the addEventListener() method I was using is not supported in Internet Explorer 8 and earlier versions.
I am very sorry for any confusion.
If you are using TWebBrowser component in Delphi for displaying the webpage do note that by default it running in Internet Explorer 7 compatibility mode.
In order to avoid this you need to opt your program into browser emulation feature
How to have Delphi TWebbrowser component running in IE9 mode?
Don't forget to check MSDN documentation for proper registry value to enable emulation of most modern IE versions.
I can't figure out how to use imacros with JavaScript. I have looked at their Help, have seen countless examples here on Stack Overflow, but don't know what am missing. It has not been explained clearly anywhere.
Here is what I tried:
Used the example explained in their help file here:
http://wiki.imacros.net/JavaScript
But nothing happens when I click the 'Click Here to Run' link (even in IE with ActiveX). NOTE: I don't have imacros for IE - the example shown above has image of the macro start in IE, but run in Firefox. And no further explanation..
Tried to import a JS file into imacros, but it doesn't seem to be working for me.
When I use code like the following:
var macro;
macro = "CODE:";
macro += "XXXXXX" + "\n";
macro += "XXXXXX" + "\n";
....
iimPlay(macro);
It says:
"Error -1100: Unknown command: VAR at line: 1"
Tried to use the above inside a script tag of an HTML page, & load the functions on page-load/click. But that doesn't work either.
What am I doing wrong, and what do I need to do?
Soon after I posted this, I think I got it to work for a while. I was able to open a JS file which opened a URL. So I had deleted the Q. But now it isn't working again, and I can't figure out why.. Can somebody help?
Basically I am having the exact same problem as this person here:
Javascript and Imacro to Open Google.com I get the same 'unknown command: var' as him. And their question remains unresolved too.
It looks like you are trying to run javascript inside an iim file. Open notepad or another text editor and paste the following code:
var test;
test ="CODE:";
test +="SET !ERRORIGNORE YES "+"\n";
test +="URL GOTO=www.google.com "+"\n";
iimPlay(test)
Save the file with a .js extension. Next open up firefox and the iMacros addon. Go to Manage -> Settings -> Paths Tab -> Folder Datasource. Enter the path where you saved the file above. Refresh iMacros by clicking the iMacro button on and off. The javascript file should show up in the left pane. Run the file to test.
You should notice the icon to the left of the file name is different for the javascript files and the extension is ".js" instead of ".iim".
Good answer Creamstout83
I would also add this to answer above. Un checking this option will speed up the process. And checking it will enable better debugging.
If you're experiencing this problem while using Chrome to run iMacros; the answer is really simple:
Download Firefox and run the iMacros plugin on there.
I experienced the same problem, receiving the error message: "Error -1100: Unknown command: VAR at line: 1", while using Chrome.
But with Firefox I can now run javascript files, have more options to play around with, and less bugs to disrupt my scrapes.
I'm writing a UserScript (=Greasemonkey) which I am developing in FireFox but works in Opera, FF and Chrome. I changed my entire script in Firefox, replacing all texts with variables as to be able to port the script easily to other languages. Now it no longer runs in Opera and it doesn't show any errors in the console (Dragonfly). The script does nothing at all, so there must be some syntax error that Firefox can handle but Opera not.
I do not use any specific FireFox features (GM_*), as I said: I only replaced strings in the scripts with variables defined in a new "translation" array.
Code to insert my script:
(
function()
{
var script = document.createElement("script");
script.textContent = "(" + myFunctionName + ")()";
document.body.appendChild(script);
}
)();
So...
Is there some JavaScript stuff that Firefox can handle but Opera not?
Or can I get the error console to work for a UserScript?
I did some googling and searched these forums but couldn't find anything that worked...
PS: I posted this on the Opera forums first but figured I have a much better chance getting a way to find a "debugging work-around" on SOF.
PPS: In the meanwhile I also tried locating the problem with JS Lint but that one gives an error when you as much as sneeze.
The message console (Ctrl+Shift+O) should contain errors from UserScripts. Alternatively, you could try packaging your script into an extension and use Dragonfly for debugging: http://dev.opera.com/articles/view/converting-userjs-to-extensions/
I used WebBrowser.XULRUNNER_SERVICE to construct an instance of com.ibm.rcp.browser.service.WebBrowser.
I have a piece of javascript code that I need to call the webBrowser's execute() method
webBrowser.execute(test);
It works fine on both Windows and Linux, and the webBrowser.execute(test); returns true.
It does not work on Mac at all. webBrowser.execute(test); returns false.
I put in a simple alert message right at the first of the javascript code.
String e0 = new String("alert(\'step 0 \');" + "\n");
I can see this alert box on Windows and Linux, but I don't see that on Mac.
Is this a known Mozilla bug?
Thanks.
I'm using jQuery for my app and I'm getting this error in IE:
Line: 13
Char: 9
Error: Expected Identifier, string or number
Code: 0
..well, as you can see, the error isn't quite helpful. How do you fix those weird IE errors? Is there any tool or a list of error descriptions that tells you what to fix?
Thanks
I would suggest looking at line 13 of your JS file to find out where the error is.
FWIW, the "Expected Identifier, string or number" error often occurs when you have a trailing comma in a list or object declaration. Firefox doesn't mind this, but IE does.
Here's an article on debugging javascript in IE. IE8 comes with a built-in debugger.
The IE Script debugger is quite OK.
But try Mozilla's error console first. It has sane line numbering. Maybe the errors are identical.
Make sure you have Microsoft Office installed
In IE, go to Tools -> Internet Options -> Advanced tab
From there UNCHECK "Disable script debugging (Internet Explorer)"
Then when a script creates an error, you will be presented with a dialog box:
Click the YES button to sign your life over to microsoft to start the debugger.
This is a really tedious workflow (the default sound that happens when a script bug is encountered is really annoying) so I don't think its a good way to work, recommend firefox error console over it any day.
See also.