[Gambas-user] how to click a check button on a web page?

Doriano Blengino doriano.blengino at ...1909...
Tue Feb 23 17:57:35 CET 2010


Ivan Williams ha scritto:
> Greetings
>
> I am writing a web app that checks a web page status periodically and if certain events occur, I need to click a button on the web page.  Can someone point me to some sample code to do this with.  I already have the code in place to check the status of the page but the button click is evading me.
>   
Uhm... not easy at all...

Look at the source of the page. If it is a "good" page, then you will 
see something like:

    <form>
    ...
    <button> name=... ... method="GET" (or: method="POST")
    ...
    </form>

In that case, you must construct an http request which resolves to 
something like "http://ahost.com/cgi-bin/...?blah1=1&blah2=anothervalue&..."

The above is good for "method=get"; everything following the "?" are 
couples of "name=value" taken from the other elements of the form. If 
method is "post", things get more complicated because you must send data 
along with the http request, instead of encoding the data in the URL. 
Fortunately, sometimes, you can use GET even if the form says "POST"; 
sometimes, you can even ignore values.

If the button is linked to a javascript routine (you see something like 
<button> onclick="..."), I don't know. You should convince  your browser 
to execute the code... sounds difficult. Are you using the gambas 
browser component? May be that you find something about it; I've never 
used it and I don't know it - sorry.

Regards,
Doriano





More information about the User mailing list