Login, fill in forms, logout

B

Barry Margolin

Can I do the following with Javascript?

My state has a web site that can be used for online filing for
unemployment benefits. Every week I have to go to the site and fill in
a form, checking off the same boxes each time. I'd like to automate
this.

I need to load the URL for the login page into the browser, fill in my
username and password, and submit the form. From that page I need to
follow a link to file for benefits. There I need to fill in the form by
checking a few boxes and submit the form. This brings up another form
where I have to confirm the entries. Then finally I can select the
Logout link.

How would I go about automating that with Javascript? I don't need
someone to write the whole thing, just provide the basic processes. I
had a similar question a few weeks ago, when I was trying to create a
bookmarklet to open my web banking page and prefill the account number,
but I was never able to solve it (I'm making do with two bookmarks -- a
regular one to open the page, and a bookmarklet to fill in the account#
field once the page is loaded). This makes me think that my plan for
the unemployment page won't work either, but there's no harm in asking.
 
L

Lasse Reichstein Nielsen

[fill in form]
How would I go about automating that with Javascript? I don't need
someone to write the whole thing, just provide the basic processes. I
had a similar question a few weeks ago, when I was trying to create a
bookmarklet to open my web banking page and prefill the account number,
but I was never able to solve it

Bookmarklets should do it. You should remember the size limit on
bookmarklets in IE if that is your browser (250 characters IIRC).

Example (make one line and change names to use):

javascript:var f=document.forms[0],v="value";f.name[v]="My name";
f.account[v]="My account";f.sometingElse.checked=true;
f.someSelect.seletedIndex=4;f.submit():

Using "[v]" instead of ".value" saves three characters each time
it is used, and cost 10 to declare, so you need to use it more than
three times for the shorthand to pay off.
If you need to use "selectedIndex" or "checked" more than once or
twice, make it a variable too, in the same way as v="value" . It's
all about saving space :)


/L
 
B

Barry Margolin

Lasse Reichstein Nielsen said:
[fill in form]
How would I go about automating that with Javascript? I don't need
someone to write the whole thing, just provide the basic processes. I
had a similar question a few weeks ago, when I was trying to create a
bookmarklet to open my web banking page and prefill the account number,
but I was never able to solve it

Bookmarklets should do it. You should remember the size limit on
bookmarklets in IE if that is your browser (250 characters IIRC).

I'm using Safari on Mac OS X 10.3.2 (so no Visual Basic, although I've
been wondering if AppleScript might work).
Example (make one line and change names to use):

javascript:var f=document.forms[0],v="value";f.name[v]="My name";
f.account[v]="My account";f.sometingElse.checked=true;
f.someSelect.seletedIndex=4;f.submit():

Using "[v]" instead of ".value" saves three characters each time
it is used, and cost 10 to declare, so you need to use it more than
three times for the shorthand to pay off.
If you need to use "selectedIndex" or "checked" more than once or
twice, make it a variable too, in the same way as v="value" . It's
all about saving space :)

Where in that bookmarklet does it go from page to page to page? After
submitting the login form, it needs to do the equivalent of clicking on
a link to get to the "file for benefits" form.

When I tried to write my previous bookmarklet, I tried assigning to
window.location to get it to load a new page, and then assign to the
form fields. The problem was that page loading happens asynchronously,
so the field assignments were being done *before* the page was actually
loaded (I could tell this was happening because if I ran the Javascript
while I was already looking at the form page, I could see it briefly
fill in the fields before reloading with an unfilled version of the
form).

What I need is a way to assign to window.location and then wait for the
browser to finish loading the page.

BTW, my ideal goal would be to do this all unattended. I'd like to set
up a cron job, so that every week this just happens automatically,
without me needing to click on anything at all. Since I'm using OS X,
which is Unix, if anyone has Unix CLI-based suggestions I'd be open to
that as well.
 
L

Lasse Reichstein Nielsen

Barry Margolin said:
Where in that bookmarklet does it go from page to page to page?

It doesn't. You would then click another bookmarklet for the next page.


If youare using IE, you could look into a HTA-file, which is a HTML
file with extra permissions. Put the page you want into an iframe
and monitor it from the HTA-page.
BTW, my ideal goal would be to do this all unattended.

In that case, I wouldn't use a browser at all. Perhaps Perl, if you
know how :)
I'd like to set up a cron job, so that every week this just happens
automatically, without me needing to click on anything at all.

Definitly not a browser :)

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top