Scripting Firefox

Hello everybody,

as you may tell from my limited number of posts (this is the first one… :)) I am fairly new to AppleScripting but already hooked…

I would like to automate some online banking I now perform manually.
As far as I can see by browsing it’s AppleScript library, Firefox has very limited scripting capabilities, still they might be sufficient…
For instance.

tell application "Firefox"
	OpenURL "http://bbs.applescript.net/viewforum.php?id=2"
end tell

will start Firefox and get the URL of the Applescript forum in MacScripter.

Now, suppose I want to login to a service (my bank account), how can that be done?
May be it’s better to refrase and ask “If” there is a way to do that?
Do we need JavaScript perhaps?
And where can I go from here?
And would it be possible to script a transaction?
If not with Firefox, could this be done with Safari?

Your help on the subject would be much appreciated :slight_smile:

Thanks in advance

/P

You need to use gui scripting which allows you to access buttons and text fileds etc in applications that are not otherwise applescriptable. Start here… http://www.apple.com/applescript/uiscripting/

Thanks regulus, for the prompt reply but…
Whow! that looks far to difficult for my limited skills. :confused:
It seems to me like I have to become first a professional programmer, in order to do what I wish.
I am sure there must be an easier way…

Perhaps somebody could come up with some, simple, practical exemples on how to login to a site Using Firefox and AppleScript and, after that, send some info?

Again, any help would be immensely appreciated.

/P

Hi KA

The GUI scripting stuff in my experience can be more tricky then normal scripting in some cases.
So my advice would be to just search this forum like crazy and be prepared to get stressed out alot.
I don’t have firefox but try something like this to start you off!:

tell application "Safari"
	open location "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&ltmpl=cm_googlemail&ltmplcache=2"
end tell
delay 1
tell application "System Events"
	tell process "Safari"
		set frontmost to true
		keystroke "username"
		keystroke tab
		keystroke "password"
		-- keystroke return --(if you uncomment this it will click the sign in button) not getting you anywhere unless you have an account with this username & password though!!
	end tell
end tell

Hi pidge,
thank you for answering my post.

I have checked out your advise but there is something that I do not understand.

If I use it the way it is, I get correctly prompted for the Google Login page with the UserID and password blocks already filled in.
It only needs a return to continue but if I try changing the “username” and “password” strings with my own, sometimes it ends in filling the URL box and search box with them.

I have tried increasing the delay and that seems to fix the problem, so does running the script twice.

I think the script just needs to be made a bit more robust as apparently, the script doesn’t know really where to place the text hence, if page loading is not completed, it will place the text in the first available boxes.
But at least I am moving now.

BTW, it works also for Firefox :slight_smile:

/P

Hi KA

GUI scripting is a blunt instrument and should be treated that way in most cases!
What works on one machine won’t always work on another due to various factors (cpu! , internet connection etc…)
Like i said prepare to get stressed!!

Gud Luck

KA, could you post what you have so far I’d like to trry it out and see If I can fixit up aliitle

mm

For this kind of www interaction, my best two advices are:

  1. Use javascript for simple tasks (ie, Safari’s “do javascript” command).
  2. Use the “curl” command-line tool for serious tasks.

There are lots of examples of both things in this forum :wink:

Hi there mcgrailm, I am glad to see this forum section is quite active… :slight_smile:

To be honest though, there isn’t much more so far.

As I mentioned before, all I want to do basically, is loggin into my online banking service by filling in a browser form and sending the requested information automatically.

I have tried pidges1 AppleScript which seems to be going into the right direction but probably needs some refinement.

For instance, is it possible to automatically check if the page is fully loaded?
Would there be something that can position the cursor precisely into the needed field for filling in a form?
Moreover, could you please explain the difference, if any, between
openURL I used with Firefox and
open location pidges1 used with his script?

Thanks for your help.

/P

Hola jj, thank you for your reply.

Would the above work with Firefox as well?
All buried into the same Applescript?
I am asking this due to the limited scripting library of Firefox.

Gracias

/P

I think the difference is just the difference between the two application dictionarys (how you talk to the app)

I too agree that what you want to do would be better handled using javascript I’m not sure how you would go about it but I’m sure that it could be done all the javascript I have written has been included as part of the web page.

mm

De nada :stuck_out_tongue:

Nope. The best option for Firefox would be writing a XUL extension (to my poor knowledge about this topic, a mix of XML and javascript).

But you have various browsers including this applescript-javascript bridge, including Safari, Camino, Omniweb… And now also Smile (“the free script editor from Satimage”) with its brand new “web window” class… You could even write your own applescriptjavascriptable application in AppleScript Studio, using a simple web view.

So, I’d go for Safari (or others).

Anyway, depending on the task, you could also create a bookmark with the required javascript (which should work in Firefox and all other browsers). This one, for example, will search for “blah” if you choose it when www.google.com is in your browser:

OK guys,

thank you to everybody for the rather incouraging information received so far.

I understand among other things that I have to further dig into matters related to AppleScripting prior to come back here with some more specific questions. :wink:
I certainly will as wonderfull tasks can be mastered with AppleScript, but that will need some time spent reading the information already available in the forum.

Cheers

/P