Include JavaScript File in iMacro Browser

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Include JavaScript File in iMacro Browser

by cycLife on Wed Jul 12, 2017 3:08 pm

Hi,

I'm having a problem including JavaScript in the iMacros Browser. I need to use the iMacros Browser since it is the only way to simulate the enter press with Direct Screen.

e.g. this function, like it is stated in this post http://forum.imacros.net/viewtopic.php?t=12204, doesn't work with the iMacros Browser, it returns the error message "Error -1100: Wrong format of URL GOTO=javascript:[...] command, at line: 9"
Code: Select all
URL GOTO=javascript:(function(){for(var i=0;i<15;i++){alert(i);}})();


to run a javascript file straight from the iMacros Browser won't work. I then receive an error message like: "Error -1100: Unknown command: VAR at line: 4"

So to explain what I would like to do is to write a Macro that opens up different webpages with the value of a csv file and to search I have to press enter. So far everything is working! Only to include the JavaScript file as an action in each loop doesn't work.

System Information
1. I'm using the newest version of iMacros (V11.5.499.3066)
2. Windows 10, German
3. All iMacros Demo Scripts are working (Firefox .js files & Macros for iMacro Browser)

Thank you in advance!
Chris
cycLife
 
Posts: 2
Joined: Wed Jul 12, 2017 4:01 am

Re: Include JavaScript File in iMacro Browser

by chivracq on Wed Jul 12, 2017 3:48 pm

cycLife wrote:System Information
Code: Select all
1. I'm using the newest version of iMacros (V11.5.499.3066)
2. Windows 10, German
3. All iMacros Demo Scripts are working (Firefox .js files & Macros for iMacro Browser)


Hi,

I'm having a problem including JavaScript in the iMacros Browser. I need to use the iMacros Browser since it is the only way to simulate the enter press with Direct Screen.

e.g. this function, like it is stated in this post http://forum.imacros.net/viewtopic.php?t=12204, doesn't work with the iMacros Browser, it returns the error message
Code: Select all
"Error -1100: Wrong format of URL GOTO=javascript:[...] command, at line: 9"

Code: Select all
URL GOTO=javascript:(function(){for(var i=0;i<15;i++){alert(i);}})();


to run a javascript file straight from the iMacros Browser won't work. I then receive an error message like: "Error -1100: Unknown command: VAR at line: 4"

So to explain what I would like to do is to write a Macro that opens up different webpages with the value of a csv file and to search I have to press enter. So far everything is working! Only to include the JavaScript file as an action in each loop doesn't work.

System Information
1. I'm using the newest version of iMacros (V11.5.499.3066)
2. Windows 10, German
3. All iMacros Demo Scripts are working (Firefox .js files & Macros for iMacro Browser)

Thank you in advance!
Chris

To bypass that RuntimeError, you need to replace the Space in "var i=..." with "var<SP>i=...". (Same for the original Thread you linked to...)

Not sure btw I understand why you need 15x 'alert()' in the 'URL GOTO' Statement, doesn't really make sense... :?

And if the "real" goal of your Script is to simulate an 'ENTER', you can probably achieve that in all Browsers now using the 'EVENT' Mode...
You don't really need the 'DS' Mode for that, unless you are dealing with a Flash Object...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6481
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Include JavaScript File in iMacro Browser

by cycLife on Thu Jul 13, 2017 8:01 am

To bypass that RuntimeError, you need to replace the Space in "var i=..." with "var<SP>i=...". (Same for the original Thread you linked to...)

Not sure btw I understand why you need 15x 'alert()' in the 'URL GOTO' Statement, doesn't really make sense... :?

And if the "real" goal of your Script is to simulate an 'ENTER', you can probably achieve that in all Browsers now using the 'EVENT' Mode...
You don't really need the 'DS' Mode for that, unless you are dealing with a Flash Object...


Thank you chivracq for the quick an helpful reply! the alerts were just for the pupose of testing :D!
Now I can play the javascrip file without an error. Neverthelesse I still can't download the .txt file through the javascript code. I've tested the javascript code by pasting it in the console of chrome or firefox and it works. Is it possible that by calling the javascript file with URL GOTO a new URL is beeing "display" so the javascript code won't find the actual page? Is there another possibility?

I've alos tried the event mode, the keypress and mousdown event works fine but the enter press doesn't unfortunately. If you mean this bit of code @chivracq

Code: Select all
EVENT TYPE=MOUSEDOWN SELECTOR="#tasks>DIV>DIV>INPUT" BUTTON=0
EVENTS TYPE=KEYPRESS SELECTOR="#tasks>DIV>DIV>INPUT" CHARS="asdf"
'EVENT TYPE=KEYPRESS SELECTOR="#tasks>DIV>DIV>INPUT" KEY=13
EVENTS TYPE=KEYPRESS SELECTOR="#tasks>DIV>DIV>INPUT" KEYS="[37,13]"
cycLife
 
Posts: 2
Joined: Wed Jul 12, 2017 4:01 am

Re: Include JavaScript File in iMacro Browser

by chivracq on Thu Jul 13, 2017 9:00 am

cycLife wrote:Thank you chivracq for the quick an helpful reply! the alerts were just for the pupose of testing :D!
Now I can play the javascrip file without an error. Neverthelesse I still can't download the .txt file through the javascript code. I've tested the javascript code by pasting it in the console of chrome or firefox and it works. Is it possible that by calling the javascript file with URL GOTO a new URL is beeing "display" so the javascript code won't find the actual page? Is there another possibility?

I've alos tried the event mode, the keypress and mousdown event works fine but the enter press doesn't unfortunately. If you mean this bit of code @chivracq

Code: Select all
EVENT TYPE=MOUSEDOWN SELECTOR="#tasks>DIV>DIV>INPUT" BUTTON=0
EVENTS TYPE=KEYPRESS SELECTOR="#tasks>DIV>DIV>INPUT" CHARS="asdf"
'EVENT TYPE=KEYPRESS SELECTOR="#tasks>DIV>DIV>INPUT" KEY=13
EVENTS TYPE=KEYPRESS SELECTOR="#tasks>DIV>DIV>INPUT" KEYS="[37,13]"

Hum, I've never seen a Download being initiated from an 'URL GOTO=javascript' Statement, iMacros has a Built-in 'ONDOWNLOAD' Mechanism/Command that relies on the Download Functionality built in the Page itself, or the 'SAVEAS' Command that imitates the Browser 'Save Page as' Mechanism...

Concerning the 'EVENT' Mode, yep, your Script looks OK, except for the 'MOUSEDOWN' Statement which normally gets paired with a 'MOUSEMOVE' + a 'MOUSEUP', or should probably be a 'CLICK' instead, but that whole Statement is probably not needed at all, so that shouldn't really play a role...

Hum, the 'DS' Mode works with Coordinates, so you cannot check/compare the 'SELECTOR' part...
You can maybe try to fire the 'ENTER' at some higher Level than your 'INPUT' Field:
Code: Select all
EVENTS TYPE=KEYPRESS SELECTOR="#tasks>DIV>DIV>INPUT" CHARS="asdf"
WAIT SECONDS=0.2
EVENT TYPE=KEYPRESS SELECTOR=* KEY=13

And if typing the first Letters of some Keyword retrieves some Entries, adding some mini-'WAIT' Statement before the 'ENTER' could help as well...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6481
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 8 guests

-->